Created
October 27, 2016 07:01
-
-
Save echo-devnull/58c1cd5a45869ebdf1bd5535e3c4026d to your computer and use it in GitHub Desktop.
Ansible Playbook to patch Debian and RedHat based servers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# This playbook patches dirty cow | |
- hosts: all | |
gather_facts: true | |
tasks: | |
- name: Grouping! | |
group_by: | |
key: "{{ ansible_os_family }}" | |
- hosts: Debian | |
gather_facts: false | |
serial: 1 | |
become: yes | |
max_fail_percentage: 0 | |
tasks: | |
- name: New linux-image-generic installation | |
apt: | |
name: linux-image-generic | |
state: latest | |
update_cache: yes | |
cache_valid_time: 600 | |
register: upgraded | |
- name: reboot | |
shell: shutdown -r now | |
when: upgraded.changed | |
register: reboot | |
- name: Wait for the server to come back | |
wait_for: | |
host: "{{ ansible_ssh_host | default(inventory_hostname) }}" | |
delay: 30 | |
state: started | |
search_regex: OpenSSH | |
port: 22 | |
become: false | |
when: reboot.changed | |
delegate_to: localhost | |
- hosts: RedHat | |
gather_facts: false | |
serial: 1 | |
become: yes | |
max_fail_percentage: 0 | |
tasks: | |
- name: Yum update the kernel | |
package: | |
name: kernel | |
state: latest | |
register: upgraded | |
- name: reboot | |
shell: shutdown -r now | |
when: upgraded.changed | |
register: reboot | |
- name: Wait for the server to come back | |
wait_for: | |
host: "{{ ansible_ssh_host | default(inventory_hostname) }}" | |
delay: 30 | |
state: started | |
search_regex: OpenSSH | |
port: 22 | |
become: false | |
when: reboot.changed | |
delegate_to: localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello... what does this playbook do exactly? I Think that only put kernel in last version... I'm I right?