Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lifecycle: build inventory and wait for instances #6113

Draft
wants to merge 3 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions ansible/configs/ocp4-cluster/lifecycle_hook_post_start.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
---
# Post Start actions for OCP 4 Cluster configs

- name: Build inventory
hosts: localhost
connection: local
gather_facts: false
become: false
tasks:
- when: cloud_provider == 'ec2'
name: Run infra-ec2-create-inventory Role
include_role:
name: infra-ec2-create-inventory

- when: cloud_provider == 'osp'
name: Run infra-osp-create-inventory Role
include_role:
name: infra-osp-create-inventory

- name: Azure post start actions
when: cloud_provider == 'azure'
include_role:
name: infra-azure-create-inventory

- name: Set ansible_ssh_extra_args
hosts:
- all:!windows:!network
gather_facts: false
any_errors_fatal: true
ignore_errors: false
tasks:
- name: Set facts for remote access
set_fact:
ansible_ssh_extra_args: >-
{{ ansible_ssh_extra_args|d() }}
-F {{hostvars.localhost.output_dir}}/{{ env_type }}_{{ guid }}_ssh_conf

- name: Run recover cluster actions
hosts: bastions
run_once: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
---
# Post Start actions for OCP 4 Cluster configs

- name: Build inventory
hosts: localhost
connection: local
gather_facts: false
become: false
tasks:
- when: cloud_provider == 'ec2'
block:
- name: Run infra-ec2-create-inventory Role
include_role:
name: infra-ec2-create-inventory

- name: Run Common SSH Config Generator Role
include_role:
name: infra-common-ssh-config-generate
when: "'bastions' in groups"

- name: Set ansible_ssh_extra_args
hosts:
- all:!windows:!network
gather_facts: false
any_errors_fatal: true
ignore_errors: false
tasks:
- name: Set facts for remote access
set_fact:
ansible_ssh_extra_args: >-
{{ ansible_ssh_extra_args|d() }}
-F {{hostvars.localhost.output_dir}}/{{ env_type }}_{{ guid }}_ssh_conf

- name: Run recover cluster actions
hosts: bastions
run_once: true
Expand Down
40 changes: 0 additions & 40 deletions ansible/configs/sap-integration/lifecycle_hook_post_start.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,5 @@
---
# Post Start actions for OCP 4 Cluster configs

- name: Build inventory
hosts: localhost
connection: local
gather_facts: false
become: false
tasks:
- when: cloud_provider == 'ec2'
name: Run infra-ec2-create-inventory Role
include_role:
name: infra-ec2-create-inventory

- when: cloud_provider == 'osp'
name: Run infra-osp-create-inventory Role
include_role:
name: infra-osp-create-inventory

- when: cloud_provider == 'azure'
name: Run infra-azure-create-inventory Role
include_role:
name: infra-azure-create-inventory

- name: Run Common SSH Config Generator Role
include_role:
name: infra-common-ssh-config-generate
when: "'bastions' in groups"

- name: Set ansible_ssh_extra_args
hosts:
- all:!windows:!network
gather_facts: false
any_errors_fatal: true
ignore_errors: false
tasks:
- name: Set facts for remote access
set_fact:
ansible_ssh_extra_args: >-
{{ ansible_ssh_extra_args|d() }}
-F {{hostvars.localhost.output_dir}}/{{ env_type }}_{{ guid }}_ssh_conf

- name: Run recover cluster actions
hosts: bastions
run_once: true
Expand Down
13 changes: 13 additions & 0 deletions ansible/lifecycle_entry_point.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
})
}}

- name: Wait for instances to be up and build inventory before calling hooks
vars:
_params:
files:
- configs/{{ env_type }}/lifecycle_hook_post_{{ ACTION }}.yml
- configs/{{ env_type }}/lifecycle_hook.yml
- noop.yml
import_playbook: >-
{{ 'noop.yml' if 'noop.yml'
in lookup('first_found', _params)
else 'lifecycle_wait_and_build_inventory.yml'
}}

- name: Call Lifecycle Post Hook
vars:
_params:
Expand Down
34 changes: 34 additions & 0 deletions ansible/lifecycle_wait_and_build_inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: Build inventory
hosts: localhost
connection: local
gather_facts: false
become: false
tasks:
- name: Run infra-{{ cloud_provider }}-create-inventory Role
include_role:
name: infra-{{ cloud_provider }}-create-inventory


# include global vars again, for all hosts
- import_playbook: include_vars.yml
tags:
- create_inventory
- must

- name: Set ansible_ssh_extra_args and wait for connection
hosts:
- all:!windows:!network
gather_facts: false
any_errors_fatal: true
ignore_errors: false
tasks:
- name: Set facts for remote access
set_fact:
ansible_ssh_extra_args: >-
{{ ansible_ssh_extra_args|d() }}
-F {{hostvars.localhost.output_dir}}/{{ env_type }}_{{ guid }}_ssh_conf

- name: Run infra-generic-wait_for_linux_hosts Role
include_role:
name: infra-generic-wait_for_linux_hosts
7 changes: 7 additions & 0 deletions ansible/noop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Noop play for plumbing: it allows fallback to an existing file/play
- hosts: localhost
name: noop
connection: local
become: false
gather_facts: false