Commit 1166a5bc by arbabnazar

rewrite ansible tasks using YAML syntax

parent 92acf889
...@@ -22,5 +22,4 @@ ...@@ -22,5 +22,4 @@
# #
- include: security-ubuntu.yml - include: security-ubuntu.yml
when: when: ansible_distribution == 'Ubuntu'
- ansible_distribution == 'Ubuntu'
---
#### Enable periodic security updates #### Enable periodic security updates
- name: Install security packages
apt:
name: "{{ item }}"
state: latest
update_cache: yes
with_items: "{{ security_debian_pkgs }}"
- name: install security packages
apt: name={{ item }} state=latest update_cache=yes
with_items: security_debian_pkgs
- name: Update all system packages
- name: update all system packages apt:
apt: upgrade=safe upgrade: safe
when: SECURITY_UPGRADE_ON_ANSIBLE when: SECURITY_UPGRADE_ON_ANSIBLE
- name: configure periodic unattended-upgrades - name: Configure periodic unattended-upgrades
template: > template:
src=etc/apt/apt.conf.d/10periodic src: "etc/apt/apt.conf.d/10periodic"
dest=/etc/apt/apt.conf.d/10periodic dest: "/etc/apt/apt.conf.d/10periodic"
owner=root group=root mode=0644 owner: root
group: root
mode: "0644"
when: SECURITY_UNATTENDED_UPGRADES when: SECURITY_UNATTENDED_UPGRADES
- name: disable unattended-upgrades - name: Disable unattended-upgrades
file: path=/etc/apt/apt.conf.d/10periodic state=absent file:
path: "/etc/apt/apt.conf.d/10periodic"
state: absent
when: not SECURITY_UNATTENDED_UPGRADES when: not SECURITY_UNATTENDED_UPGRADES
- name: only unattended-upgrade from security repo - name: Only unattended-upgrade from security repo
template: > template:
src=etc/apt/apt.conf.d/20unattended-upgrade src: "etc/apt/apt.conf.d/20unattended-upgrade"
dest=/etc/apt/apt.conf.d/20unattended-upgrade dest: "/etc/apt/apt.conf.d/20unattended-upgrade"
owner=root group=root mode=0644 owner: root
group: root
mode: "0644"
when: SECURITY_UNATTENDED_UPGRADES and not SECURITY_UPDATE_ALL_PACKAGES when: SECURITY_UNATTENDED_UPGRADES and not SECURITY_UPDATE_ALL_PACKAGES
- name: disable security only updates on unattended-upgrades - name: Disable security only updates on unattended-upgrades
file: path=/etc/apt/apt.conf.d/20unattended-upgrade state=absent file:
path: "/etc/apt/apt.conf.d/20unattended-upgrade"
state: absent
when: SECURITY_UPDATE_ALL_PACKAGES or not SECURITY_UNATTENDED_UPGRADES when: SECURITY_UPDATE_ALL_PACKAGES or not SECURITY_UNATTENDED_UPGRADES
#### Bash security vulnerability #### Bash security vulnerability
- name: Check if we are vulnerable - name: Check if we are vulnerable
shell: executable=/bin/bash chdir=/tmp foo='() { echo vulnerable; }' bash -c foo shell: "executable=/bin/bash chdir=/tmp foo='() { echo vulnerable; }' bash -c foo"
register: test_vuln register: test_vuln
ignore_errors: yes ignore_errors: yes
- name: Apply bash security update if we are vulnerable - name: Apply bash security update if we are vulnerable
apt: name=bash state=latest update_cache=true apt:
name: bash
state: latest
update_cache: yes
when: "'vulnerable' in test_vuln.stdout" when: "'vulnerable' in test_vuln.stdout"
- name: Check again and fail if we are still vulnerable - name: Check again and fail if we are still vulnerable
shell: executable=/bin/bash foo='() { echo vulnerable; }' bash -c foo shell: "executable=/bin/bash foo='() { echo vulnerable; }' bash -c foo"
when: "'vulnerable' in test_vuln.stdout" when: "'vulnerable' in test_vuln.stdout"
register: test_vuln register: test_vuln
failed_when: "'vulnerable' in test_vuln.stdout" failed_when: "'vulnerable' in test_vuln.stdout"
...@@ -52,20 +66,23 @@ ...@@ -52,20 +66,23 @@
#### GHOST security vulnerability #### GHOST security vulnerability
- name: GHOST.c - name: GHOST.c
copy: > copy:
src=tmp/GHOST.c src: "tmp/GHOST.c"
dest=/tmp/GHOST.c dest: "/tmp/GHOST.c"
owner=root group=root owner: root
group: root
- name: compile GHOST - name: Compile GHOST
shell: gcc -o /tmp/GHOST /tmp/GHOST.c shell: "gcc -o /tmp/GHOST /tmp/GHOST.c"
- name: Check if we are vulnerable - name: Check if we are vulnerable
shell: /tmp/GHOST shell: "/tmp/GHOST"
register: test_ghost_vuln register: test_ghost_vuln
ignore_errors: yes ignore_errors: yes
- name: Apply glibc security update if we are vulnerable - name: Apply glibc security update if we are vulnerable
apt: name=libc6 state=latest update_cache=true apt:
name: libc6
state: latest
update_cache: yes
when: "'vulnerable' in test_ghost_vuln.stdout" when: "'vulnerable' in test_ghost_vuln.stdout"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment