playbook.yml delegate_to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
--- - name: My playbook create file hosts: all become: yes vars: mytext: "Privet ot b14esh" tasks: - name: Test ping ping: - name: Create File file1.txt copy: dest: /home/file1.txt content: | This is file1.txt On ohhh {{ mytext }} delegate_to: linux1 - name: Create file file2.txt copy: dest: /home/file2.txt content: | This is File2 Mytext {{ mytext }} lol lol lol lol lol ... |
playbook.yml delegate_to на ansible master 127.0.0.1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
--- - name: My playbook create file hosts: all become: yes vars: mytext: "Privet ot b14esh" tasks: - name: Test ping ping: - name: Unregister Server from Load Balance shell: echo this server {{ inventory_hostname }} was deregisterred from our load balancer, node name is {{ ansible_nodename }} >> /home/log.txt delegate_to: 127.0.0.1 - name: Create File file1.txt copy: dest: /home/file1.txt content: | This is file1.txt On ohhh {{ mytext }} delegate_to: linux1 - name: Create file file2.txt copy: dest: /home/file2.txt content: | This is File2 Mytext {{ mytext }} lol lol lol lol lol ... |
playbook.yml delegate_to , run_once выполнить один раз , reboot и ждем
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
--- - name: My playbook create file hosts: all become: yes vars: mytext: "Privet ot b14esh" tasks: - name: Test ping ping: - name: Unregister Server from Load Balance shell: echo this server {{ inventory_hostname }} was deregisterred from our load balancer, node name is {{ ansible_nodename }} >> /home/log.txt delegate_to: 127.0.0.1 - name: Update my database shell: echo Update database run_once: true delegate_to: 127.0.0.1 - name: Create File file1.txt copy: dest: /home/file1.txt content: | This is file1.txt On ohhh {{ mytext }} delegate_to: linux1 - name: Create file file2.txt copy: dest: /home/file2.txt content: | This is File2 Mytext {{ mytext }} lol lol lol lol lol - name: reboot my servers shell: sleep 4 && reboot now async: 1 poll: 0 - name: wait my server will come online wait_for: host: "{{ inventory_hostname }}" state: started delay: 5 timeout: 40 delegate_to: 127.0.0.1 ... |