below is my update_nginx_all_config.yml file
<code>---
- hosts: test
tasks:
- include: copy_vhosts_config.yml
- include: copy_stream_config.yml
- include: copy_whitelist_config.yml
- include: copy_gas_config.yml
- include: copy_all_file_under_nginx_folder.yml
</code>
<code>---
- hosts: test
tasks:
- include: copy_vhosts_config.yml
- include: copy_stream_config.yml
- include: copy_whitelist_config.yml
- include: copy_gas_config.yml
- include: copy_all_file_under_nginx_folder.yml
</code>
---
- hosts: test
tasks:
- include: copy_vhosts_config.yml
- include: copy_stream_config.yml
- include: copy_whitelist_config.yml
- include: copy_gas_config.yml
- include: copy_all_file_under_nginx_folder.yml
and below is copy_vhosts_config.yml
<code>- name: copy vhosts file
copy:
src: /home/fee_admin/gitlab_ansible/gitlab_ansible_master/ansible/ansible-playbook/nginx/conf/vhosts/
dest: /home/fee/runtime/nginx/conf/vhosts
owner: fee
group: fee
mode: "0644"
diff: yes
</code>
<code>- name: copy vhosts file
copy:
src: /home/fee_admin/gitlab_ansible/gitlab_ansible_master/ansible/ansible-playbook/nginx/conf/vhosts/
dest: /home/fee/runtime/nginx/conf/vhosts
owner: fee
group: fee
mode: "0644"
diff: yes
</code>
- name: copy vhosts file
copy:
src: /home/fee_admin/gitlab_ansible/gitlab_ansible_master/ansible/ansible-playbook/nginx/conf/vhosts/
dest: /home/fee/runtime/nginx/conf/vhosts
owner: fee
group: fee
mode: "0644"
diff: yes
Now I have encountered one issue, which is whenever I ran
<code>ansible-playbook --diff -i hosts -b update_nginx_all_config.yml
</code>
<code>ansible-playbook --diff -i hosts -b update_nginx_all_config.yml
</code>
ansible-playbook --diff -i hosts -b update_nginx_all_config.yml
the output only showed
<code>xxxx@xxxxx:~/gitlab_ansible/gitlab_ansible_master/ansible/ansible-playbook$ ansible-playbook --diff -i hosts -b update_nginx_all_config.yml
PLAY [test] ********************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *********************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [copy vhosts file] ********************************************************************************************************************************************************************************************
changed: [34.333.222.111]
TASK [copy stream file] ********************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [copy whitelist file] *****************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [copy gas file] ***********************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [Find files under /home/fee_admin/gitlab_ansible/gitlab_ansible_master/ansible/ansible-playbook/nginx/conf] ***************************************************************************************************
ok: [34.333.222.111 -> localhost]
...
</code>
<code>xxxx@xxxxx:~/gitlab_ansible/gitlab_ansible_master/ansible/ansible-playbook$ ansible-playbook --diff -i hosts -b update_nginx_all_config.yml
PLAY [test] ********************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *********************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [copy vhosts file] ********************************************************************************************************************************************************************************************
changed: [34.333.222.111]
TASK [copy stream file] ********************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [copy whitelist file] *****************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [copy gas file] ***********************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [Find files under /home/fee_admin/gitlab_ansible/gitlab_ansible_master/ansible/ansible-playbook/nginx/conf] ***************************************************************************************************
ok: [34.333.222.111 -> localhost]
...
</code>
xxxx@xxxxx:~/gitlab_ansible/gitlab_ansible_master/ansible/ansible-playbook$ ansible-playbook --diff -i hosts -b update_nginx_all_config.yml
PLAY [test] ********************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *********************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [copy vhosts file] ********************************************************************************************************************************************************************************************
changed: [34.333.222.111]
TASK [copy stream file] ********************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [copy whitelist file] *****************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [copy gas file] ***********************************************************************************************************************************************************************************************
ok: [34.333.222.111]
TASK [Find files under /home/fee_admin/gitlab_ansible/gitlab_ansible_master/ansible/ansible-playbook/nginx/conf] ***************************************************************************************************
ok: [34.333.222.111 -> localhost]
...
As you can see, something changed during the execution for TASK [copy vhosts file], but I just showed [changed] instead of printing out what has been changed.
By the way, I also enable diff in ansible.cfg