c12s-kubespray/roles/bootstrap-os/tasks/main.yml
Erwan Miran 87193fd270 Fix ansible syntax to avoid ansible warnings (one more) (#3536)
* warning on meta flush_handlers

* avoid rm

* avoid "Module remote_tmp /root/.ansible/tmp did not exist and was created with a mode of 0700, this may cause issues when running as another user. To avoid this, create the remote_tmp dir with the correct permissions manually" warning on subsequent tasks using blockinfile

* is match
2018-10-17 12:27:11 -07:00

76 lines
2.1 KiB
YAML

---
- name: Fetch /etc/os-release
raw: cat /etc/os-release
register: os_release
changed_when: false
- name: Set bootstrap_os
set_fact:
os_family: >-
{%- if 'Ubuntu' in os_release.stdout -%}
ubuntu
{%- elif 'Debian' in os_release.stdout -%}
debian
{%- elif 'CoreOS' in os_release.stdout -%}
coreos
{%- elif 'Fedora' in os_release.stdout -%}
fedora
{%- elif 'CentOS' in os_release.stdout -%}
centos
{%- elif 'OpenSUSE' in os_release.stdout -%}
opensuse
{% endif %}
- include_tasks: bootstrap-ubuntu.yml
when: os_family == "ubuntu"
- include_tasks: bootstrap-debian.yml
when: os_family == "debian"
- include_tasks: bootstrap-coreos.yml
when: os_family == "coreos"
- include_tasks: bootstrap-fedora.yml
when: os_family == "fedora"
- include_tasks: bootstrap-centos.yml
when: os_family == "centos"
- include_tasks: bootstrap-opensuse.yml
when: os_family == "opensuse"
- import_tasks: setup-pipelining.yml
- name: Create remote_tmp for it is used by another module
file:
path: "{{ lookup('config', 'DEFAULT_REMOTE_TMP', on_missing='skip', wantlist=True) | first | default('~/.ansible/tmp') }}"
state: directory
mode: 0700
- name: Gather nodes hostnames
setup:
gather_subset: '!all'
filter: ansible_*
- name: Assign inventory name to unconfigured hostnames (non-CoreOS and Tumbleweed)
hostname:
name: "{{inventory_hostname}}"
when:
- override_system_hostname
- ansible_distribution not in ['openSUSE Tumbleweed']
- ansible_os_family not in ['CoreOS', 'Container Linux by CoreOS']
- name: Assign inventory name to unconfigured hostnames (CoreOS and Tumbleweed only)
command: "hostnamectl set-hostname {{inventory_hostname}}"
register: hostname_changed
when:
- ansible_hostname == 'localhost'
- ansible_distribution in ['openSUSE Tumbleweed'] or ansible_os_family in ['CoreOS', 'Container Linux by CoreOS']
- override_system_hostname
- name: Update hostname fact (CoreOS and Tumbleweed only)
setup:
gather_subset: '!all'
filter: ansible_hostname
when:
- hostname_changed.changed