homeserver/roles/robertdebock.bootstrap/tasks/gather_facts.yml

30 lines
989 B
YAML
Raw Normal View History

2021-02-13 14:20:18 +01:00
---
- name: Lookup bootstrap facts
ansible.builtin.raw: "cat /etc/os-release"
2021-02-13 14:20:18 +01:00
become: no
check_mode: no
register: bootstrap_facts
changed_when: no
- name: Set bootstrap facts (I)
ansible.builtin.set_fact:
2021-02-13 14:20:18 +01:00
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') }}"
2021-02-13 14:20:18 +01:00
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
2021-02-13 14:20:18 +01:00
- name: Set bootstrap facts (II)
ansible.builtin.set_fact:
2021-02-13 14:20:18 +01:00
bootstrap_os_family: "{{ item.key }}"
loop: "{{ bootstrap_os_family_map | dict2items }}"
loop_control:
label: "{{ item.key }}"
when:
- bootstrap_distribution in item.value
become: no