I am making my own small cluster server and configuring everything through Ansible but I am a bit stuck on checking whether or not a variable has been inserted into /boot/firmware/cmdline.txt
or not.
Assume group_vars/all.yml
contains the following definition:
cgroup_vars:
- 'cgroup_enable=cpuset'
- 'cgroup_memory=1'
- 'cgroup_enable=memory'
I load the content into a variable with the following tasks in my playbook:
- name: Read cmdline.txt for use below.
shell: 'cat /boot/firmware/cmdline.txt'
register: cmdline
- name: Get individual environmental variables from cmdline.txt
set_fact:
cmd_vars: "{{ cmdline.stdout | split() }}"
Output of {{ cmd_vars | to_nice_yaml }}
would be something like:
msg: |-
- console=serial0,115200
- console=tty1
- root=PARTUUID=52e8c2a3-02
- rootfstype=ext4
- fsck.repair=yes
- rootwait
- cgroup_enable=cpuset
- cgroup_memory=1
- cgroup_enable=memory
This should leave me with two lists: cgroup_vars
and cmd_vars
.
How do I check that all items in cgroup_vars
is found in cmd_vars
?
I would prefer that the result is a new list that contains the answer if the individual item was found or not.