De Wiki inetshell
Saltar a: navegación, buscar


[Ansible vs Puppet An Overview of the Solutions ]


- name: Check if reboot is required
    path: /var/run/reboot-required
  register: reboot_required_file

# In a normal play, the pause action is only executed once, not once-per-host.
# In this case, we really want to force the once-per-host thing.
# ref
- name: Prompt for rebooting
    prompt: "Press ENTER to reboot {{ item }} now, or Ctrl+C to abort."
  # We need to check for the existence of 'reboot_required_file' first because play_hosts also
  # include hosts that have failed. When a host has failed, it stops executing and thus doesn't
  # have 'reboot_required_file'. And if we try to access 'stat', boom! failure. We don't want that.
  when: "'reboot_required_file' in hostvars[item] and hostvars[item]['reboot_required_file'].stat.exists"
  with_items: "{{ play_hosts }}"

# ref
- name: Rebooting machine
  shell: sleep 2 && shutdown -r now "Ansible updates triggered"
  async: 1
  poll: 0
  ignore_errors: true
  when: reboot_required_file.stat.exists

- name: Waiting for the machine to come back
  local_action: wait_for host={{ ansible_host }} state=started port=22 delay=30
  become: no
  when: reboot_required_file.stat.exists

Actualizacion de parametros de SSH[editar]