Skip to content

Instantly share code, notes, and snippets.

@seomin3
Created February 28, 2019 08:50
Show Gist options
  • Select an option

  • Save seomin3/74cde0df03009c8eb1dccee7771b51d9 to your computer and use it in GitHub Desktop.

Select an option

Save seomin3/74cde0df03009c8eb1dccee7771b51d9 to your computer and use it in GitHub Desktop.
reboot after change selinux config
- name: turn off selinux
selinux:
policy: targeted
state: permissive
register: selinux_result
- name: check kernel cmdline
lineinfile:
dest: /proc/cmdline
line: "user_namespace.enable=1"
check_mode: yes
register: find_cmdline_result
- debug:
var: find_cmdline_result
- name: enable user namespace
lineinfile:
dest: /etc/sysconfig/grub
regexp: '(GRUB_CMDLINE_LINUX=)"(.*)"'
line: '\1"\2 user_namespace.enable=1"'
backrefs: yes
state: present
backup: yes
when: find_cmdline_result is changed
- name: apply to grub
command: grub2-mkconfig -o /boot/grub2/grub.cfg
when: find_cmdline_result is changed
- name: Reboot immediately if there was a change.
shell: "sleep 5 && reboot"
async: 1
poll: 0
when: selinux_result is changed or find_cmdline_result is changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment