Include Files to Extend Playbook:
Breaks up long playbooks.
Used to add external variable files.
Reuse other playbooks.
Example
Register task output:
Grab output of task to another task.
Useful to use tasks to feed data into other tasks.
Useful to create custom error trapping
Debug Module:
Add debug to tasks.Not same as in -vvv option.
It can receive 2 parameters.
1. msg -- as a message
2. var -- output result as a variable
Instead of complete output of the results, we can just get the portion we want like this, results.stdout_lines
Useful to send output to screen during execution.
Helps find problems
Breaks up long playbooks.
Used to add external variable files.
Reuse other playbooks.
tasks: - include: wordpress.yml vars: sitename: My Awesome Site - include: loadbalancer.yml - include_vars: variables.yml
Example
Register task output:
Grab output of task to another task.
Useful to use tasks to feed data into other tasks.
Useful to create custom error trapping
tasks: - shell: /usr/bin/whoami register: username - file: path=/home/myfile.txt owner={{ username }}
Debug Module:
Add debug to tasks.Not same as in -vvv option.
It can receive 2 parameters.
1. msg -- as a message
2. var -- output result as a variable
--- - hosts: centos vars: - var_thing: "some message" tasks: - name: show results debug: msg="the variable var_thing is set to - {{ var_thing }}"
--- - hosts: centos vars: - var_thing: "some message" tasks: - name: echo stuff command: echo -e "{{ var_thing }} give you up, \n {{ var_thing }} let you down, \n{{ var_thing }} run around and dessert you" register: results - name: show results debug: msg="{{ results }}"
Instead of complete output of the results, we can just get the portion we want like this, results.stdout_lines
Useful to send output to screen during execution.
Helps find problems
tasks: - debug: msg="This host is {{ inventory_hostname }} during execution" - shell: /usr/bin/whoami register: username - debug: var=username
No comments:
Post a Comment