Clark Boylan 60acea0da6 Run latest ansible-lint on Ubuntu Noble
We bump the Ansible version to the version that Zuul runs. We then set
ansible-lint to the current latest version. This results in a number of
new linter violations which we fix. These violations include:

 * Needing to name plays
 * Needing to start names with a capital letter
 * Using fully qualified names for action modules
 * Quoting permissions strings to avoid octal conversion errors
 * Using explicit yaml structures for tasks

We also tell ansible-lint to mock zuul_return so that we don't get
errors from it complaining that this module is not defined.

Change-Id: Ic881313fea58f4482f70e493f3d256541d31860a
2024-10-07 12:36:32 -07:00

68 lines
2.3 KiB
YAML

---
# On RAX hosts, we have a small root partition and a large,
# unallocated ephemeral device attached at /dev/xvde
- name: Set ephemeral device if /dev/xvde exists
when: ansible_devices["xvde"] is defined
set_fact:
ephemeral_device: "/dev/xvde"
# On other providers, we have a device called "ephemeral0".
#
# NOTE(ianw): Once [1] is in our ansible (2.4 era?), we can figure
# this out more directly by walking the device labels in the facts
#
# [1] https://github.com/ansible/ansible/commit/d46dd99f47c0ee5081d15bc5b741e9096d8bfd3e
- name: Set ephemeral device by label
when: ephemeral_device is undefined
block:
- name: Get ephemeral0 device node
command: /sbin/blkid -L ephemeral0
register: ephemeral0
# rc !=0 is expected
failed_when: False
changed_when: False
- name: Set ephemeral device if LABEL exists
when: "ephemeral0.rc == 0"
set_fact:
ephemeral_device: "{{ ephemeral0.stdout }}"
# If we have ephemeral storage and we don't appear to have setup swap,
# we will create a swap and move /opt to a large data partition there.
- name: Setup swap on ephemeral storage
include_tasks: ephemeral.yaml
when:
- ephemeral_device is defined
- ansible_memory_mb['swap']['total'] | int + 10 <= configure_swap_size
# If no ephemeral device and no swap, then we will setup some swap
# space on the root device to ensure all hosts a consistent memory
# environment.
- name: Setup swap file on root device
include_tasks: root.yaml
when:
- ephemeral_device is undefined
- ansible_memory_mb['swap']['total'] | int + 10 <= configure_swap_size
# ensure a standard level of swappiness. Some platforms
# (rax+centos7) come with swappiness of 0 (presumably because the
# vm doesn't come with swap setup ... but we just did that above),
# which depending on the kernel version can lead to the OOM killer
# kicking in on some processes despite swap being available;
# particularly things like mysql which have very high ratio of
# anonymous-memory to file-backed mappings.
#
# This sets swappiness low; we really don't want to be relying on
# cloud I/O based swap during our runs if we can help it
- name: Set swappiness
become: yes
ansible.posix.sysctl:
name: vm.swappiness
value: 30
state: present
- name: Debug the ephemeral_device variable
debug:
var: ephemeral_device