I have a playbook where I would like to do a task once before starting a couple roles and once after roles with serial 1. I thought I could accomplish this with pre and post tasks but it looks like they are called once per server.
--- - name: Pre Post Task Test hosts: "linux" gather_facts: false any_errors_fatal: true serial: 1 pre_tasks: - shell: echo "pre" tasks: - shell: echo "tasks" post_tasks: - shell: echo "post" Results in: PLAY [Hello World Linux] **************************************************************************************************************************** TASK [command] ************************************************************************************************************************************** changed: [mdl-swch01] => {"changed": true, "cmd": "echo \"pre\"", "delta": "0:00:00.002576", "end": "2018-02-14 15:27:31.198276", "rc": 0, "start": "2018-02-14 15:27:31.195700", "stderr": "", "stderr_lines": [], "stdout": "pre", "stdout_lines": ["pre"]} TASK [command] ************************************************************************************************************************************** changed: [mdl-swch01] => {"changed": true, "cmd": "echo \"tasks\"", "delta": "0:00:00.003271", "end": "2018-02-14 15:27:37.240087", "rc": 0, "start": "2018-02-14 15:27:37.236816", "stderr": "", "stderr_lines": [], "stdout": "tasks", "stdout_lines": ["tasks"]} TASK [command] ************************************************************************************************************************************** changed: [mdl-swch01] => {"changed": true, "cmd": "echo \"post\"", "delta": "0:00:00.002614", "end": "2018-02-14 15:27:43.294444", "rc": 0, "start": "2018-02-14 15:27:43.291830", "stderr": "", "stderr_lines": [], "stdout": "post", "stdout_lines": ["post"]} PLAY [Hello World Linux] **************************************************************************************************************************** TASK [command] ************************************************************************************************************************************** changed: [mdl-swch02] => {"changed": true, "cmd": "echo \"pre\"", "delta": "0:00:00.002461", "end": "2018-02-14 15:27:44.875867", "rc": 0, "start": "2018-02-14 15:27:44.873406", "stderr": "", "stderr_lines": [], "stdout": "pre", "stdout_lines": ["pre"]} TASK [command] ************************************************************************************************************************************** changed: [mdl-swch02] => {"changed": true, "cmd": "echo \"tasks\"", "delta": "0:00:00.002899", "end": "2018-02-14 15:27:45.271244", "rc": 0, "start": "2018-02-14 15:27:45.268345", "stderr": "", "stderr_lines": [], "stdout": "tasks", "stdout_lines": ["tasks"]} TASK [command] ************************************************************************************************************************************** changed: [mdl-swch02] => {"changed": true, "cmd": "echo \"post\"", "delta": "0:00:00.002650", "end": "2018-02-14 15:27:45.664172", "rc": 0, "start": "2018-02-14 15:27:45.661522", "stderr": "", "stderr_lines": [], "stdout": "post", "stdout_lines": ["post"]} PLAY RECAP ****************************************************************************************************************************************** mdl-swch01 : ok=3 changed=3 unreachable=0 failed=0 mdl-swch02 : ok=3 changed=3 unreachable=0 failed=0 I am looking for something that would do: pre tasks tasks for mdl-swch01 tasks for mdl-swch02 post tasks Any ideas on how to accomplish this? -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/61aa41c2-3ecc-4822-8644-cd68308d8d7f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.