Difference between revisions of "Ansible print and debug examples"
Jump to navigation
Jump to search
(14 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
+ | <nowiki> | ||
#!/usr/bin/env ansible-playbook | #!/usr/bin/env ansible-playbook | ||
− | + | ||
- hosts: localhost | - hosts: localhost | ||
gather_facts: no | gather_facts: no | ||
Line 8: | Line 9: | ||
tasks: | tasks: | ||
− | - name: | + | - name: My first task for executing hello world |
command: echo test | command: echo test | ||
− | - name: | + | - name: My second task debug message name |
debug: | debug: | ||
msg: "my debug text" | msg: "my debug text" | ||
− | - name: | + | - name: My third task to print a text and variable |
debug: | debug: | ||
msg: "my debug text including var {{ my_var }}" | msg: "my debug text including var {{ my_var }}" | ||
+ | </nowiki> | ||
</pre> | </pre> | ||
+ | |||
== Output == | == Output == | ||
+ | <pre> | ||
+ | |||
+ | PLAY [localhost] ************************************************************************************************************************************* | ||
+ | |||
+ | TASK [My first task for executing hello world] ******************************************************************************************************* | ||
+ | changed: [localhost] | ||
+ | |||
+ | TASK [My second task debug message name] ************************************************************************************************************* | ||
+ | ok: [localhost] => { | ||
+ | "msg": "my debug text" | ||
+ | } | ||
+ | |||
+ | TASK [My third task to print a text and variable] **************************************************************************************************** | ||
+ | ok: [localhost] => { | ||
+ | "msg": "my debug text including var MY_VALUE" | ||
+ | } | ||
+ | |||
+ | PLAY RECAP ******************************************************************************************************************************************* | ||
+ | localhost : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 | ||
+ | </pre> | ||
+ | |||
+ | == Related == | ||
+ | * [[Ansible variables]] | ||
+ | * [[Msg: The task includes an option with an undefined variable.]] | ||
== See also == | == See also == | ||
+ | * {{print}} | ||
* {{ansible}} | * {{ansible}} | ||
[[Category:Ansible]] | [[Category:Ansible]] |
Latest revision as of 16:13, 11 August 2022
#!/usr/bin/env ansible-playbook - hosts: localhost gather_facts: no vars: my_var: MY_VALUE tasks: - name: My first task for executing hello world command: echo test - name: My second task debug message name debug: msg: "my debug text" - name: My third task to print a text and variable debug: msg: "my debug text including var {{ my_var }}"
Output[edit]
PLAY [localhost] ************************************************************************************************************************************* TASK [My first task for executing hello world] ******************************************************************************************************* changed: [localhost] TASK [My second task debug message name] ************************************************************************************************************* ok: [localhost] => { "msg": "my debug text" } TASK [My third task to print a text and variable] **************************************************************************************************** ok: [localhost] => { "msg": "my debug text including var MY_VALUE" } PLAY RECAP ******************************************************************************************************************************************* localhost : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Related[edit]
See also[edit]
print, strcat, echo
- Ansible: modules, plugins, Playbooks (examples)
ansible-playbook
,ansible-vault
,ansible-inventory
,ansible-config
, Ansible Tower, Ansible Galaxy (Roles) (ansible-galaxy
),ansible-cmdb
,gather facts
,ansible.cfg
,Ansible Molecule
, Ansible collections,register
,template
,--ask-pass
,--ask-become-pass
,remote_user:
,/etc/ansible/hosts
,ansible-doc
,ansible-lint
,.ansible/
,--forks
,--start-at-task
,changelog
,inventory
,Notify:
,ansible HOSTNAME -m ping
,gathering
,/usr/bin/ansible
,ansible -m ping
,ansible.builtin
,hosts: (Ansible)
,set fact:
,when:
,blockinfile:
,become method:
,include:
,git:
, AWX,ansible --help
, Tags, Ansible variables, versions
Advertising: