Skip to content

Instantly share code, notes, and snippets.

@jmpolom
Created October 20, 2021 17:04
Show Gist options
  • Save jmpolom/ed63b4cac5e9034591a71a40f16970d8 to your computer and use it in GitHub Desktop.
Save jmpolom/ed63b4cac5e9034591a71a40f16970d8 to your computer and use it in GitHub Desktop.
Ansible playbook prototype to modify rpm-ostree kargs
- name: search test
hosts: localhost
connection: local
gather_facts: no
vars:
kargs: "resume=/dev/mapper/fedora-swap rd.lvm.lv=fedora/root rd.luks.uuid=luks-6937d598-6a2f-4019-bb29-924f5c34467a rd.lvm.lv=fedora/swap rhgb quiet console=tty1 console=ttyS0,115200n8 ip=dhcp"
karg_ip: "ip=dhcp"
additional_kargs: []
tasks:
- name: compile kargs to add
ansible.builtin.set_fact:
additional_kargs: "{{ additional_kargs + [item] }} "
when: kargs is not search(item)
loop:
- "console=tty1"
- "console=ttyS0,115200n8"
- "console=ttyS1,115200n8"
- name: add ip arg if none exists already
ansible.builtin.set_fact:
additional_kargs: "{{ additional_kargs + [{{ karg_ip }}] }}"
when: kargs is not search(" ip=")
register: ip_exist
- name: update ip arg if a general version exists already and there's not an exact match
ansible.builtin.debug:
msg: "sudo rpm-ostree kargs --replace=ip={{ karg_ip }}"
when:
- ip_exist is not changed
- kargs is not search(karg_ip)
- name: update args
ansible.builtin.debug:
msg: "{{ additional_kargs | join(' ') }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment