---
- hosts:  "{{ dc | default('all') }}"
  gather_facts: no
  serial: "{{ serial | default(1) }}"
  tasks:

  - name: upgrade kernel package
    sudo: yes
    yum:
      name: kernel
      state: latest
    register: kernel

  - name: upgrade all packages
    sudo: yes
    yum:
      name: "*"
      state: latest

  - name: reboot host
    sudo: yes
    shell: nohup bash -c "sleep 2s && reboot" &
    register: reboot
    when: kernel.changed

  - name: wait for host boot
    local_action:
      module: wait_for
      host: "{{ ansible_ssh_host }}"
      port: 22
      delay: "{{ boot_wait | default(60) }}"
      timeout: 120
      state: started
    when: reboot.changed

---
- hosts:  "{{ dc | default('all') }}"
  gather_facts: no
  serial: "{{ serial | default(1) }}"
  tasks:

  - name: refresh yum cache
    sudo: yes
    command: yum makecache

  - name: upgrade kernel package
    sudo: yes
    yum:
      name: kernel
      state: latest
    register: kernel

  - name: upgrade all packages
    sudo: yes
    yum:
      name: "*"
      state: latest

  - name: reboot host
    sudo: yes
    shell: nohup bash -c "sleep 2s && reboot" &
    register: reboot
    when: kernel.changed

  - name: wait for host boot
    local_action:
      module: wait_for
      host: "{{ ansible_ssh_host }}"
      port: 22
      delay: "{{ boot_wait | default(60) }}"
      timeout: 120
      state: started
    when: reboot.changed

Refresh yum cache. Rollout of CentOS 7.1 was causing package installs to fail without this.
Refresh yum cache. Rollout of CentOS 7.1 was causing package installs to fail without this.
