homeserver/roles/robertdebock.bootstrap/tasks/gather_facts.yml
mg 686a0b281f Rolle aktualisiert: bootstrap (#457)
Co-authored-by: Michael Grote <michael.grote@posteo.de>
Reviewed-on: #457
2023-02-17 12:06:35 +01:00

29 lines
989 B
YAML

---
- name: Lookup bootstrap facts
ansible.builtin.raw: "cat /etc/os-release"
become: no
check_mode: no
register: bootstrap_facts
changed_when: no
- name: Set bootstrap facts (I)
ansible.builtin.set_fact:
bootstrap_distribution: "{{ item }}"
bootstrap_distribution_major_version: "{{ bootstrap_facts.stdout_lines | join(',') | regex_replace('^.*VERSION_ID=\"(\\d{1,2})(\\.\\d{1,4})*?\".*$', '\\1') | default('NA') }}"
loop: "{{ bootstrap_os_family_map | dict2items | map(attribute='value') | flatten }}"
when:
- bootstrap_facts.rc == 0
- bootstrap_distribution is not defined
- bootstrap_facts.stdout is regex('PRETTY_NAME=.'~ bootstrap_search[item] | default(item) ~'.*')
become: no
- name: Set bootstrap facts (II)
ansible.builtin.set_fact:
bootstrap_os_family: "{{ item.key }}"
loop: "{{ bootstrap_os_family_map | dict2items }}"
loop_control:
label: "{{ item.key }}"
when:
- bootstrap_distribution in item.value
become: no