You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.9 KiB

8 years ago
  1. ---
  2. - name: Fetch /etc/os-release
  3. raw: cat /etc/os-release
  4. register: os_release
  5. changed_when: false
  6. - name: Set bootstrap_os
  7. set_fact:
  8. os_family: >-
  9. {%- if 'Ubuntu' in os_release.stdout -%}
  10. ubuntu
  11. {%- elif 'Debian' in os_release.stdout -%}
  12. debian
  13. {%- elif 'CoreOS' in os_release.stdout -%}
  14. coreos
  15. {%- elif 'Fedora' in os_release.stdout -%}
  16. fedora
  17. {%- elif 'CentOS' in os_release.stdout -%}
  18. centos
  19. {%- elif 'OpenSUSE' in os_release.stdout -%}
  20. opensuse
  21. {% endif %}
  22. - include_tasks: bootstrap-ubuntu.yml
  23. when: os_family == "ubuntu"
  24. - include_tasks: bootstrap-debian.yml
  25. when: os_family == "debian"
  26. - include_tasks: bootstrap-coreos.yml
  27. when: os_family == "coreos"
  28. - include_tasks: bootstrap-fedora.yml
  29. when: os_family == "fedora"
  30. - include_tasks: bootstrap-centos.yml
  31. when: os_family == "centos"
  32. - include_tasks: bootstrap-opensuse.yml
  33. when: os_family == "opensuse"
  34. - import_tasks: setup-pipelining.yml
  35. - name: Gather nodes hostnames
  36. setup:
  37. gather_subset: '!all'
  38. filter: ansible_*
  39. - name: Assign inventory name to unconfigured hostnames (non-CoreOS and Tumbleweed)
  40. hostname:
  41. name: "{{inventory_hostname}}"
  42. when:
  43. - override_system_hostname
  44. - ansible_distribution not in ['openSUSE Tumbleweed']
  45. - ansible_os_family not in ['CoreOS', 'Container Linux by CoreOS']
  46. - name: Assign inventory name to unconfigured hostnames (CoreOS and Tumbleweed only)
  47. command: "hostnamectl set-hostname {{inventory_hostname}}"
  48. register: hostname_changed
  49. when:
  50. - ansible_hostname == 'localhost'
  51. - ansible_distribution in ['openSUSE Tumbleweed'] or ansible_os_family in ['CoreOS', 'Container Linux by CoreOS']
  52. - override_system_hostname
  53. - name: Update hostname fact (CoreOS and Tumbleweed only)
  54. setup:
  55. gather_subset: '!all'
  56. filter: ansible_hostname
  57. when:
  58. - hostname_changed.changed