Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Stop relying on old legacy sub_nodes_private
Browse files Browse the repository at this point in the history
Add subnodes to the inventory.

Change-Id: I335f0bba2ca9c3e7e427e9247692c5c0d17b4087
  • Loading branch information
rafaelfolco authored and rlandy committed Sep 7, 2018
1 parent 6c7340d commit b1c53d9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/nodes/1ctlr.yml
Expand Up @@ -9,7 +9,7 @@ node_count: 1

deployed_server_overcloud_roles:
- name: Controller
hosts: "$(sed -n 1,1p /etc/nodepool/sub_nodes_private)"
hosts: "{{ subnodes.0 }}"

topology: >-
--compute-scale 0
Expand Down
4 changes: 2 additions & 2 deletions config/nodes/2ctlr.yml
Expand Up @@ -13,9 +13,9 @@ node_count: 2

deployed_server_overcloud_roles:
- name: ControllerApi
hosts: $(sed -n 1,1p /etc/nodepool/sub_nodes_private)
hosts: "{{ subnodes.0 }}"
- name: Controller
hosts: "$(sed -n 2,2p /etc/nodepool/sub_nodes_private)"
hosts: "{{ subnodes.1 }}"

topology: >-
--compute-scale 0
Expand Down
55 changes: 47 additions & 8 deletions roles/tripleo-inventory/tasks/inventory.yml
Expand Up @@ -39,21 +39,60 @@
ansible_private_key_file: "{{ overcloud_key }}"
ansible_ssh_extra_args: '-F "{{ local_working_dir }}/ssh.config.ansible"'

- when: inventory == 'multinode'
- name: check existence of legacy nodepool directory
stat:
path: /etc/nodepool/sub_nodes_private
register: stat_subnodes_private_result

- when: inventory == 'multinode' and stat_subnodes_private_result.stat.exists == True
block:
- name: Get subnodes
command: cat /etc/nodepool/sub_nodes_private
register: nodes

- name: Add subnode to ansible inventory
with_indexed_items: '{{ nodes.stdout_lines | default([]) }}'
- name: Create empty subnodes
set_fact:
subnodes: "[]"

- name: Add subnodes info from legacy nodepool directory
set_fact:
subnodes: "{{ subnodes }} + [item]"
with_items: '{{ nodes.stdout_lines | default([]) }}'

- name: Add subnode to ansible inventory
with_indexed_items: "{{ subnodes }}"
add_host:
name: 'subnode-{{ item.0 + 2 }}'
groups: "overcloud"
ansible_host: "{{ item.1 }}"
inventory_ip: "{{ item.1 }}"
ansible_user: "{{ lookup('env','USER') }}"
ansible_private_key_file: "/home/{{ ansible_user }}/.ssh/id_rsa"
when: inventory == 'multinode'

- name: check existence of legacy nodepool primary node file
stat:
path: /etc/nodepool/primary_node_private
register: stat_primary_node_result

- when: inventory == 'multinode' and stat_primary_node_result.stat.exists == True
block:
- name: Get primary nodes
command: cat /etc/nodepool/primary_node_private
register: primary_node_private

- name: Create primary_node
set_fact:
primary_node: "{{ primary_node_private.stdout | default('') }}"

- name: Add primary_node to ansible inventory
add_host:
name: 'subnode-{{ item.0 + 2 }}'
groups: "overcloud"
ansible_host: '{{ item.1 }}'
inventory_ip: '{{ item.1 }}'
name: 'primary_node'
groups: "undercloud"
ansible_host: "{{ primary_node }}"
inventory_ip: "{{ primary_node }}"
ansible_user: "{{ lookup('env','USER') }}"
ansible_private_key_file: "/etc/nodepool/id_rsa"
ansible_private_key_file: "/home/{{ ansible_user }}/.ssh/id_rsa"

#required for regeneration of ssh.config.ansible
- name: set_fact for undercloud ip
Expand Down

0 comments on commit b1c53d9

Please sign in to comment.