Tasks YAML
How you config tasks.yaml file.
Basic Structure YAML of tasks.yaml file.
---
opsshell:
- name: Task 1 on All Servers
hosts: all # Specify the host group here
os_env: # Define environment variables here
KEY: "value"
tasks:
- name: Set environment variables
command: |
echo 'export VAR1=value1' >> ~/.bashrc
echo 'export VAR2=value2' >> ~/.bashrc
source ~/.bashrc
- name: Install python 3.8
command: apt-get install -y python3.8
opsshell
is the name of the main name.- name: Task on All Servers Group
is the name of the first task within the playbook. This task appears to be intended to run on all servers in the "all" group.hosts: all
specifies the group of hosts on which this task should run. In this case, it's set to "all," which means it will run on all servers defined in the inventory hosts.yaml file.os_env:
is used to define environment variables that can be used within the playbook.KEY: "value"
sets an environment variableKEY
with the value "value." to your remote server
tasks:
is a list of tasks to be executed on the specified group hosts.
Last updated
Was this helpful?