Running the playbook
the command to run the playbook is a little different than the regular run command:
ansible-playbook nginx_install.yml
output would be:
PLAY [virtualhosts] ********************************************************************************
TASK [Gathering Facts] *****************************************************************************
ok: [ubuntu-1]
ok: [ubuntu-2]
TASK [install nginx] *******************************************************************************
changed: [ubuntu-2]
changed: [ubuntu-1]
TASK [Setup nginx conf] ****************************************************************************
changed: [ubuntu-2]
changed: [ubuntu-1]
RUNNING HANDLER [restart nginx] ********************************************************************
changed: [ubuntu-1]
changed: [ubuntu-2]
PLAY RECAP *****************************************************************************************
ubuntu-1 : ok=4 changed=3 unreachable=0 failed=0
ubuntu-2 : ok=4 changed=3 unreachable=0 failed=0
playing the playbook again wont do anything if the state of the services and file is already identical:
yonit@ansible_server:~/ansible$ ansible-playbook nginx_install.yml
PLAY [virtualhosts] ********************************************************************************
TASK [Gathering Facts] *****************************************************************************
ok: [ubuntu-2]
ok: [ubuntu-1]
TASK [install nginx] *******************************************************************************
ok: [ubuntu-2]
ok: [ubuntu-1]
TASK [Setup nginx conf] ****************************************************************************
ok: [ubuntu-2]
ok: [ubuntu-1]
PLAY RECAP *****************************************************************************************
ubuntu-1 : ok=3 changed=0 unreachable=0 failed=0
ubuntu-2 : ok=3 changed=0 unreachable=0 failed=0