system-config/playbooks/roles/nodepool-base/tasks/main.yaml
Monty Taylor 8d7075b02f Run zookeeper cluster in nodepool jobs
Rather than running a local zookeeper, just run a real zookeeper.
Also, get rid of nb01-test and just use nb04 - what could possibly
go wrong?

Dynamically write zookeeper host information to nodepool.yaml

So that we can run an actual zk using the new zk role on hosts in
ansible inventory, we need to write out the ip addresses of the
hosts that we build in zuul. This means having the info baked in
to the file in project-config isn't going to work.

We can do this in prod too, it shouldn't hurt anything.

Increase timeout for run-service-nodepool

We need to fix the playbook, but we'll do that after we get the
puppet gone.

Change-Id: Ib01d461ae2c5cec3c31ec5105a41b1a99ff9d84a
2020-04-29 16:18:25 -05:00

67 lines
1.7 KiB
YAML

- name: Add the nodepool group
group:
name: nodepool
state: present
gid: '{{ nodepool_base_nodepool_gid }}'
- name: Add the nodepool user
user:
name: nodepool
group: nodepool
home: /home/nodepool
create_home: yes
shell: /bin/bash
uid: '{{ nodepool_base_nodepool_uid }}'
- name: Sync project-config
include_role:
name: sync-project-config
- name: Create nodepool config dir
file:
name: /etc/nodepool
state: directory
owner: nodepool
group: nodepool
mode: 0755
- name: Look for a host specific config file
stat:
path: /opt/project-config/nodepool/{{ inventory_hostname }}.yaml
register: host_config_file
- name: Load host specific config file
slurp:
path: '{{ host_config_file.stat.exists | ternary(host_config_file.stat.path, "/opt/project-config/nodepool/nodepool.yaml") }}'
register: nodepool_config_content
- name: Parse nodepool config
set_fact:
nodepool_config: "{{ nodepool_config_content.content | b64decode | from_yaml }}"
# Have to run service-zookeeper before service-nodepool
# because we need top populate the fact cache.
- name: Get zk config
make_nodepool_zk_hosts:
hostvars: "{{ hostvars }}"
zk_group: "{{ groups['zookeeper'] }}"
register: zk_hosts
- name: Overwrite zookeeper-servers
vars:
new_config:
zookeeper-servers: '{{ zk_hosts.hosts }}'
set_fact:
nodepool_config: "{{ nodepool_config | combine(new_config) }}"
- name: Write nodepool config
copy:
content: "{{ nodepool_config | to_nice_yaml }}"
dest: /etc/nodepool/nodepool.yaml
- name: Symlink in elements from project-config repo
file:
state: link
src: /opt/project-config/nodepool/elements
dest: /etc/nodepool/elements