tripleo-ci/playbooks/openstack-zuul-jobs/legacy/pre.yaml
Sorin Sbarnea a3c9dc40e4 Fixed yamlint violations
Change-Id: I7468ef9929cd6a7c0969bcd6befb320bfd671097
2021-02-10 15:24:59 +00:00

84 lines
2.4 KiB
YAML

---
- hosts: all
gather_facts: false
tasks:
- name: Set IP addresses for the nodes missing private IPs
set_fact:
nodepool_ip: "{{ nodepool.public_ipv4 }}"
when: not (nodepool.private_ipv4 | ipv4)
- name: Set IP addresses for the nodes without private IPs (a fallback)
set_fact:
nodepool_ip: "{{ nodepool.private_ipv4 | default(nodepool.public_ipv4) }}"
when: nodepool_ip is not defined
- hosts: all
tasks:
- name: Create nodepool directory
file:
path: /etc/nodepool
state: directory
- name: Create nodepool sub_nodes file
copy:
dest: /etc/nodepool/sub_nodes
content: ""
- name: Create nodepool sub_nodes_private file
copy:
dest: /etc/nodepool/sub_nodes_private
content: ""
- name: Populate nodepool sub_nodes file
lineinfile:
path: /etc/nodepool/sub_nodes
line: "{{ hostvars[item]['nodepool']['public_ipv4'] }}"
with_items: "{{ groups['subnodes'] }}"
when: groups['subnodes'] is defined
- name: Populate nodepool sub_nodes_private file
lineinfile:
path: /etc/nodepool/sub_nodes_private
line: "{{ hostvars[item]['nodepool_ip'] }}"
insertafter: EOF
with_items: "{{ groups['subnodes'] }}"
when: groups['subnodes'] is defined
- name: Create nodepool primary file
copy:
dest: /etc/nodepool/primary_node_private
content: "{{ hostvars['primary']['nodepool_ip'] }}"
when: hostvars['primary'] is defined
- name: Create nodepool node_private for this node
copy:
dest: /etc/nodepool/node_private
content: "{{ nodepool_ip }}"
- name: Copy ssh keys to nodepool directory
command: "cp .ssh/{{ item }} /etc/nodepool/{{ item }}"
with_items:
- id_rsa
- id_rsa.pub
changed_when: true
- name: Add sudoers role for zuul-sudo-grep.sh
copy:
dest: /etc/sudoers.d/zuul-sudo-grep
content: "zuul ALL = NOPASSWD:/usr/local/jenkins/slave_scripts/zuul-sudo-grep.sh\n"
mode: 0440
become: true
- name: Validate sudoers config after edits
command: "/usr/sbin/visudo -c"
become: true
changed_when: false
- name: Show the environment passed in to job shell scripts
command: env
args:
executable: /bin/bash
warn: false
environment: '{{ zuul | zuul_legacy_vars }}'
changed_when: false