Ansible first playbook

i am trying to execute my first ansible script and noticing no task executed
here is the playbook used inventory file & groups

I’m under the impression i should see the date & host details as per the two small tasks but nothing showd up

cat first.yml

name: 'Execute command to display date on web_node1'
hosts: nifi_test
tasks:
    -
        name: 'Execute a date command'
        command: date
  • name: ‘Execute a command to display hosts file contents on web_node2’
    hosts: nifi_test2
    tasks:
    -
    name: ‘Execute a command to display hosts file’
    command: cat /etc/hosts

ansible-playbook -i inventory.txt first.yml

PLAY [Execute command to display date on web_node1] ***********************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************
ok: [nifi_test2]
ok: [nifi_test1]

TASK [Execute a date command] *********************************************************************************************************************************
changed: [nifi_test1]
changed: [nifi_test2]

PLAY [Execute a command to display hosts file contents on web_node2] ******************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************
ok: [nifi_test2]

TASK [Execute a command to display hosts file] ****************************************************************************************************************
changed: [nifi_test2]

PLAY RECAP ****************************************************************************************************************************************************
nifi_test1 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
nifi_test2 : ok=4 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

cat inventory.txt
nifi_test1 ansible_host=10.30.abc.abc anisble_ssh_pass=passwd
nifi_test2 ansible_host=10.30.abc.abc ansible_ssh_pass=passwd

#Groups
[nifi_test]
nifi_test1
nifi_test2

Hi @venki_kancharla

We 're trying to make this course very simple to match who doesn’t have any experience in Ansible. We discussed Ansible registers in details in our Ansible advanced course :

Also, this example will be useful:

To print the output we will use both Ansible registers and debug module.

- Ansible registers : Ansible keyword to store or capture the output of a task to a variable.

For example :

  • name: execute date command: date register: date_output

You can reuse the date_output variable in subsequent play, For example, to print contents of this variable you can use the debug module :

  • debug: name: print the output msg: “{‌{ result.stdout }}”

- debug module: Print statements during execution.

The full example :

  • name: execute date hosts: all tasks: - name: execute date command: date register: date_output - debug: msg: “{‌{ date_output.stdout }}”

The result :

Hope this helps!

Thanks for the update. made very good progress in writing my own ansible code for config mgmt. thanks