summaryrefslogtreecommitdiff
path: root/playbooks/zuul-stream/create-inventory.yaml
blob: c2be027492b9052938501cf654aeb8197118382f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
- name: Copy inventory
  copy:
    src: "{{ zuul.executor.log_root }}/zuul-info/inventory.yaml"
    dest: "{{ ansible_user_dir }}/inventory.yaml"

- name: Slurp inventory
  slurp:
    path: "{{ ansible_user_dir }}/inventory.yaml"
  register: _inventory_yaml

- name: Extract inventory
  set_fact:
    _new_inventory: "{{ _inventory_yaml['content'] | b64decode | from_yaml }}"

- name: Setup new facts
  set_fact:
    _docker_inventory:
      all:
        children:
          node:
            hosts:
              node3: null
        hosts:
          node3:
            ansible_connection: ssh
            ansible_host: 127.0.0.2
            ansible_port: 2022
            ansible_user: root
            ansible_python_interpreter: /usr/local/bin/python2.7

- name: Merge all facts
  set_fact:
    _new_inventory: '{{ _new_inventory | combine(_docker_inventory, recursive=True) }}'

- name: Write out inventory
  copy:
    content: '{{ _new_inventory | to_nice_yaml }}'
    dest: '{{ ansible_user_dir }}/inventory.yaml'