Skip to content

Commit

Permalink
Update swap disable tasks
Browse files Browse the repository at this point in the history
* Lines are commented out vice being removed
* Comment is added indicating why the change happened
* Variable openshift_disable_swap added to allow user control
  • Loading branch information
mtnbikenc committed Apr 21, 2017
1 parent 6497b5a commit 393acee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
23 changes: 14 additions & 9 deletions roles/openshift_node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,33 @@
- name: Check for swap usage
command: grep "^[^#].*swap" /etc/fstab
# grep: match any lines which don't begin with '#' and contain 'swap'
# command: swapon --summary
# Alternate option, however if swap entries are in fstab, swap will be
# enabled at boot. Grepping fstab should catch a condition when swap was
# disabled, but the fstab entries were not removed.
changed_when: false
failed_when: false
register: swap_result

# Disable Swap Block
# Disable Swap Block
- block:

- name: Disable swap
command: swapoff --all

- name: Remove swap entries from /etc/fstab
replace:
dest: /etc/fstab
regexp: '(^[^#].*swap.*)'
replace: '# \1'
backup: yes

- name: Add notice about disabling swap
lineinfile:
dest: /etc/fstab
regexp: 'swap'
state: absent
line: '# OpenShift-Ansible Installer disabled swap per overcommit guidelines'
state: present

when: swap_result.stdout_lines | length > 0
# End Disable Swap Block
when:
- swap_result.stdout_lines | length > 0
- openshift_disable_swap | default(true)
# End Disable Swap Block

# We have to add tuned-profiles in the same transaction otherwise we run into depsolving
# problems because the rpms don't pin the version properly. This was fixed in 3.1 packaging.
Expand Down
19 changes: 12 additions & 7 deletions roles/openshift_node_upgrade/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@
- name: Check for swap usage
command: grep "^[^#].*swap" /etc/fstab
# grep: match any lines which don't begin with '#' and contain 'swap'
# command: swapon --summary
# Alternate option, however if swap entries are in fstab, swap will be
# enabled at boot. Grepping fstab should catch a condition when swap was
# disabled, but the fstab entries were not removed.
changed_when: false
failed_when: false
register: swap_result
Expand All @@ -114,12 +110,21 @@
command: swapoff --all

- name: Remove swap entries from /etc/fstab
replace:
dest: /etc/fstab
regexp: '(^[^#].*swap.*)'
replace: '# \1'
backup: yes

- name: Add notice about disabling swap
lineinfile:
dest: /etc/fstab
regexp: 'swap'
state: absent
line: '# OpenShift-Ansible Installer disabled swap per overcommit guidelines'
state: present

when: swap_result.stdout_lines | length > 0
when:
- swap_result.stdout_lines | length > 0
- openshift_disable_swap | default(true)
# End Disable Swap Block

# Restart all services
Expand Down

0 comments on commit 393acee

Please sign in to comment.