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.

74 lines
2.9 KiB

[jjo] add DIND support to contrib/ (#3468) * [jjo] add DIND support to contrib/ - add contrib/dind with ansible playbook to create "node" containers, and setup them to mimic host nodes as much as possible (using Ubuntu images), see contrib/dind/README.md - nodes' /etc/hosts editing via `blockinfile` and `lineinfile` need `unsafe_writes: yes` because /etc/hosts are mounted by docker, and thus can't be handled atomically (modify copy + rename) * dind-host role: set node container hostname on creation * add "Resulting deployment" section with some CLI outputs * typo * selectable node_distro: debian, ubuntu * some fixes for node_distro: ubuntu * cpu optimization: add early `pkill -STOP agetty` * typo * add centos dind support ;) * add kubespray-dind.yaml, support fedora - add kubespray-dind.yaml (former custom.yaml at README.md) - rework README.md as per above - use some YAML power to share distros' commonality - add fedora support * create unique /etc/machine-id and other updates - create unique /etc/machine-id in each docker node, used as seed for e.g. weave mac addresses - with above, now netchecker 100% passes WoHooOO! :tada: :tada: :tada: - updated README.md output from (1.12.1, verified netcheck) * minor typos * fix centos node creation, needs earlier udevadm removal to avoid flaky facts, also verified netcheck Ok \o/ * add Q&D test-distros.sh, back to manual /etc/machine-id hack * run-test-distros.sh cosmetics and minor fixes * run-test-distros.sh: $rc fix and minor formatting changes * run-test-distros.sh output cosmetics
6 years ago
[jjo] add DIND support to contrib/ (#3468) * [jjo] add DIND support to contrib/ - add contrib/dind with ansible playbook to create "node" containers, and setup them to mimic host nodes as much as possible (using Ubuntu images), see contrib/dind/README.md - nodes' /etc/hosts editing via `blockinfile` and `lineinfile` need `unsafe_writes: yes` because /etc/hosts are mounted by docker, and thus can't be handled atomically (modify copy + rename) * dind-host role: set node container hostname on creation * add "Resulting deployment" section with some CLI outputs * typo * selectable node_distro: debian, ubuntu * some fixes for node_distro: ubuntu * cpu optimization: add early `pkill -STOP agetty` * typo * add centos dind support ;) * add kubespray-dind.yaml, support fedora - add kubespray-dind.yaml (former custom.yaml at README.md) - rework README.md as per above - use some YAML power to share distros' commonality - add fedora support * create unique /etc/machine-id and other updates - create unique /etc/machine-id in each docker node, used as seed for e.g. weave mac addresses - with above, now netchecker 100% passes WoHooOO! :tada: :tada: :tada: - updated README.md output from (1.12.1, verified netcheck) * minor typos * fix centos node creation, needs earlier udevadm removal to avoid flaky facts, also verified netcheck Ok \o/ * add Q&D test-distros.sh, back to manual /etc/machine-id hack * run-test-distros.sh cosmetics and minor fixes * run-test-distros.sh: $rc fix and minor formatting changes * run-test-distros.sh output cosmetics
6 years ago
[jjo] add DIND support to contrib/ (#3468) * [jjo] add DIND support to contrib/ - add contrib/dind with ansible playbook to create "node" containers, and setup them to mimic host nodes as much as possible (using Ubuntu images), see contrib/dind/README.md - nodes' /etc/hosts editing via `blockinfile` and `lineinfile` need `unsafe_writes: yes` because /etc/hosts are mounted by docker, and thus can't be handled atomically (modify copy + rename) * dind-host role: set node container hostname on creation * add "Resulting deployment" section with some CLI outputs * typo * selectable node_distro: debian, ubuntu * some fixes for node_distro: ubuntu * cpu optimization: add early `pkill -STOP agetty` * typo * add centos dind support ;) * add kubespray-dind.yaml, support fedora - add kubespray-dind.yaml (former custom.yaml at README.md) - rework README.md as per above - use some YAML power to share distros' commonality - add fedora support * create unique /etc/machine-id and other updates - create unique /etc/machine-id in each docker node, used as seed for e.g. weave mac addresses - with above, now netchecker 100% passes WoHooOO! :tada: :tada: :tada: - updated README.md output from (1.12.1, verified netcheck) * minor typos * fix centos node creation, needs earlier udevadm removal to avoid flaky facts, also verified netcheck Ok \o/ * add Q&D test-distros.sh, back to manual /etc/machine-id hack * run-test-distros.sh cosmetics and minor fixes * run-test-distros.sh: $rc fix and minor formatting changes * run-test-distros.sh output cosmetics
6 years ago
  1. ---
  2. - name: Hosts | create list from inventory
  3. set_fact:
  4. etc_hosts_inventory_block: |-
  5. {% for item in (groups['k8s-cluster'] + groups['etcd'] + groups['calico-rr']|default([]))|unique -%}
  6. {% if 'access_ip' in hostvars[item] or 'ip' in hostvars[item] or 'ansible_default_ipv4' in hostvars[item] -%}
  7. {{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item]['ansible_default_ipv4']['address'])) }}
  8. {%- if ('ansible_hostname' in hostvars[item] and item != hostvars[item]['ansible_hostname']) %} {{ hostvars[item]['ansible_hostname'] }}.{{ dns_domain }} {{ hostvars[item]['ansible_hostname'] }}{% endif %} {{ item }}.{{ dns_domain }} {{ item }}
  9. {% endif %}
  10. {% endfor %}
  11. delegate_to: localhost
  12. connection: local
  13. delegate_facts: yes
  14. run_once: yes
  15. - name: Hosts | populate inventory into hosts file
  16. blockinfile:
  17. path: /etc/hosts
  18. block: "{{ hostvars.localhost.etc_hosts_inventory_block }}"
  19. state: present
  20. create: yes
  21. backup: yes
  22. unsafe_writes: yes
  23. marker: "# Ansible inventory hosts {mark}"
  24. when: populate_inventory_to_hosts_file
  25. - name: Hosts | populate kubernetes loadbalancer address into hosts file
  26. lineinfile:
  27. dest: /etc/hosts
  28. regexp: ".*{{ apiserver_loadbalancer_domain_name }}$"
  29. line: "{{ loadbalancer_apiserver.address }} {{ apiserver_loadbalancer_domain_name }}"
  30. state: present
  31. backup: yes
  32. unsafe_writes: yes
  33. when:
  34. - loadbalancer_apiserver is defined
  35. - loadbalancer_apiserver.address is defined
  36. - name: Hosts | Retrieve hosts file content
  37. slurp:
  38. src: /etc/hosts
  39. register: etc_hosts_content
  40. - name: Hosts | Extract existing entries for localhost from hosts file
  41. set_fact:
  42. etc_hosts_localhosts_dict: >-
  43. {%- set splitted = (item | regex_replace('[ \t]+', ' ')|regex_replace('#.*$')|trim).split( ' ') -%}
  44. {{ etc_hosts_localhosts_dict|default({}) | combine({splitted[0]: splitted[1::] }) }}
  45. with_items: "{{ (etc_hosts_content['content'] | b64decode).splitlines() }}"
  46. when:
  47. - etc_hosts_content.content is defined
  48. - (item is match('^::1 .*') or item is match('^127.0.0.1 .*'))
  49. - name: Hosts | Update target hosts file entries dict with required entries
  50. set_fact:
  51. etc_hosts_localhosts_dict_target: >-
  52. {%- set target_entries = (etc_hosts_localhosts_dict|default({})).get(item.key, []) | difference(item.value.get('unexpected' ,[])) -%}
  53. {{ etc_hosts_localhosts_dict_target|default({}) | combine({item.key: (target_entries + item.value.expected)|unique}) }}
  54. with_dict: "{{ etc_hosts_localhost_entries }}"
  55. - name: Hosts | Update (if necessary) hosts file
  56. lineinfile:
  57. dest: /etc/hosts
  58. line: "{{ item.key }} {{ item.value|join(' ') }}"
  59. regexp: "^{{ item.key }}.*$"
  60. state: present
  61. backup: yes
  62. unsafe_writes: yes
  63. with_dict: "{{ etc_hosts_localhosts_dict_target }}"
  64. # gather facts to update ansible_fqdn
  65. - name: Update facts
  66. setup:
  67. gather_subset: min