Skip to content

Instantly share code, notes, and snippets.

@tlester
Created March 4, 2019 19:31
Show Gist options
  • Save tlester/a5a413da4d19d2cfda472874a5371054 to your computer and use it in GitHub Desktop.
Save tlester/a5a413da4d19d2cfda472874a5371054 to your computer and use it in GitHub Desktop.
# Make FS for CIS compliance
- name: make filesystem for /var if needed
become: yes
filesystem:
fstype: ext4
dev: "{{ var_disk }}"
register: fs
- name: Backup /var
when: fs is changed
become: yes
block:
# Adding a yum update here, because if this is happening, it means it's a new host.
- name: upgrade all packages
yum:
name: '*'
state: latest
- name: Make temporary mount point
become: yes
mount:
name: /mnt/var
src: "{{ var_disk }}"
fstype: ext4
state: mounted
when: fs is changed
- name: Backup filesystem
become: yes
shell: cp -apx /var/* /mnt/var
- name: Unmount temp mount
become: yes
mount:
name: /mnt/var
state: absent
- name: Add /var to the filesystem but dont mount
become: yes
mount:
path: /var
src: "{{ var_disk }}"
fstype: ext4
opts: defaults,nofail
state: present
backup: yes
- name: Reboot
reboot:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment