Merge "bootstrap-host: Create swap without using a failed task"

This commit is contained in:
Zuul 2018-02-12 03:17:18 +00:00 committed by Gerrit Code Review
commit 4e1d8739bf

View File

@ -13,48 +13,56 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- block: - name: Create swap file
- name: Check if swap is already enabled command: "{{ swap_create_command }}"
command: grep /openstack/swap.img /proc/swaps args:
creates: /openstack/swap.img
register: swap_create
tags:
- swap-file-create
rescue: - name: Set swap file permissions to 0600
- name: Create swap file file:
command: "{{ swap_create_command }}" path: /openstack/swap.img
args: mode: 0600
creates: /openstack/swap.img tags:
register: swap_create - swap-permissions
tags:
- swap-file-create
- name: Set swap file permissions to 0600 - name: Format the swap file
file: command: mkswap /openstack/swap.img
path: /openstack/swap.img when: swap_create | changed
mode: 0600 tags:
tags: - swap-format
- swap-permissions
- name: Format the swap file - name: Ensure that the swap file entry is in /etc/fstab
command: mkswap /openstack/swap.img mount:
when: swap_create | changed name: none
tags: src: /openstack/swap.img
- swap-format fstype: swap
opts: sw
passno: 0
dump: 0
state: present
tags:
- swap-fstab
- name: Ensure that the swap file entry is in /etc/fstab - name: Bring swap file online
mount: shell: |
name: none return_code=0
src: /openstack/swap.img if ! grep /openstack/swap.img /proc/swaps; then
fstype: swap swapon /openstack/swap.img
opts: sw return_code=2
passno: 0 fi
dump: 0 exit ${return_code}
state: present register: _set_swap_online
tags: changed_when: _set_swap_online.rc == 2
- swap-fstab failed_when: _set_swap_online.rc not in [0, 2]
# We skip ansible lint testing for this task as it fails with
- name: Bring swap file online # ANSIBLE0014 Environment variables don't work as part of command
command: swapon /openstack/swap.img # which is nonsense.
tags: tags:
- swap-online - skip_ansible_lint
- swap-online
- name: Set system swappiness - name: Set system swappiness
sysctl: sysctl: