Difference between revisions of "Ansible print and debug examples"

From wikieduonline
Jump to navigation Jump to search
Line 8: Line 8:
  
 
   tasks:
 
   tasks:
   - name: my task for executing hello world
+
   - name: My first task for executing hello world
 
     command: echo test
 
     command: echo test
  
   - name: my debug message name
+
   - name: My second task debug message name
 
     debug:
 
     debug:
 
       msg: "my debug text"
 
       msg: "my debug text"
  
   - name: my debug message 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 }}"

Revision as of 15:07, 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


PLAY [localhost] *************************************************************************************************************************************

TASK [my task for executing hello world] *************************************************************************************************************
changed: [localhost]

TASK [my debug message name] *************************************************************************************************************************
ok: [localhost] => {
    "msg": "my debug text"
}

TASK [my debug message name] *************************************************************************************************************************
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

See also

Advertising: