Skip to content

Commit

Permalink
review and split non-provider intergration changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mtulio committed May 2, 2023
1 parent ebf7900 commit 014c9b9
Show file tree
Hide file tree
Showing 39 changed files with 455 additions and 233 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/mock-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defaults:
working-directory: 'mtulio.okd_installer'

jobs:
create_all:
create_destroy_all:
name: create-all
runs-on: ubuntu-latest
defaults:
Expand Down Expand Up @@ -110,17 +110,32 @@ jobs:
ansible-playbook mtulio.okd_installer.install_clients -e @$VARS_FILE
tree ~/.ansible/okd-installer/bin || true
- name: Create cluster (play create_all)
# step to run create_all in new environment
- name: Create cluster (play create_all/new)
env:
VARS_FILE: "./vars-${{ steps.vars.outputs.cluster-name }}.yaml"
run: |
set -x
echo "Running create_all, the stdout will be suprised..."
echo "Running create_all new infrastructure..."
./run-play-steps.sh create_all
cat ~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}/cluster_state.json || true
cat ~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}install-config-bkp.yaml || true
# step to run create_all in existing environment (immutable)
- name: Create cluster (play create_all/existing)
env:
VARS_FILE: "./vars-${{ steps.vars.outputs.cluster-name }}.yaml"
run: |
set -x
echo "Running create_all in existing infrastructure..."
# TODO: target to idepotent execution, must check change==0
./run-play-steps.sh create_all
cat ~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}/cluster_state.json || true
cat ~/.ansible/okd-installer/clusters/${{ steps.vars.outputs.cluster-name }}install-config-bkp.yaml || true
- name: Destroy cluster (play destroy_cluster)
env:
VARS_FILE: "./vars-${{ steps.vars.outputs.cluster-name }}.yaml"
Expand Down
1 change: 0 additions & 1 deletion playbooks/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
- name: okd-installer | Installer Configuration
hosts: localhost
connection: local

roles:
- config
33 changes: 24 additions & 9 deletions playbooks/create_all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,43 @@
ansible.builtin.set_fact:
okdi_call_timer_start: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}"

# - name: OKD Installer | Create all | check required vars
# ansible.builtin.import_playbook: var_check_required.yaml

- name: OKD Installer | Create all | create config
- name: OKD Installer | Create all | Config | create config
ansible.builtin.import_playbook: config.yaml
vars:
mode: create
mode: create-config

- name: OKD Installer | Create all | create stack | network
ansible.builtin.import_playbook: stack_network.yaml
- name: OKD Installer | Create all | Config | create config
ansible.builtin.import_playbook: config.yaml
vars:
mode: create-manifests

- name: OKD Installer | Create all | create stack | IAM
ansible.builtin.import_playbook: stack_iam.yaml

- name: OKD Installer | Create all | create stack | network
ansible.builtin.import_playbook: stack_network.yaml

- name: OKD Installer | Create all | create stack | DNS
ansible.builtin.import_playbook: stack_dns.yaml

- name: OKD Installer | Create all | create stack | Load Balancer
ansible.builtin.import_playbook: stack_loadbalancer.yaml

- name: OKD Installer | Create all | create stack | Compute
- name: OKD Installer | Create all | Config | patch manifests
ansible.builtin.import_playbook: config.yaml
vars:
mode: patch-manifests

- name: OKD Installer | Create all | Config | create ignitions
ansible.builtin.import_playbook: config.yaml
vars:
mode: create-ignitions

- name: OKD Installer | Create all | os_mirror
ansible.builtin.import_playbook: os_mirror.yaml
when: os_mirror | d(false)

- name: OKD Installer | Create all | create stack | Compute nodes
ansible.builtin.import_playbook: create_node_all.yaml

- name: OKD Installer | Create all | create stack | Load Balancer Router
Expand All @@ -54,7 +70,6 @@
ansible.builtin.import_playbook: destroy_bootstrap.yaml
when: destroy_bootstrap | d('yes') == 'yes'


- name: OKD Installer | Create ALL | End
hosts: '{{ target|default("localhost") }}'
connection: local
Expand Down
24 changes: 9 additions & 15 deletions playbooks/destroy_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
hosts: '{{ target|default("localhost") }}'
connection: local
gather_facts: yes

tasks:
- name: OKD Installer | Destroy | Timer start
ansible.builtin.set_fact:
okdi_del_timer_start: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}"

# - ansible.builtin.import_playbook: var_check_required.yaml

- name: okd-installer | Cluster Destroy | Config load
ansible.builtin.import_playbook: config.yaml
vars:
Expand All @@ -20,12 +17,14 @@
hosts: '{{target|default("localhost")}}'
connection: local
gather_facts: yes

vars:
profile_path: "{{ playbook_dir }}/vars/{{ config_provider }}/profiles/{{ cluster_profile|d('default') }}"

vars_files:
- "{{ profile_path }}/iam.yaml"
- "{{ profile_path }}/dns.yaml"

pre_tasks:
# Network
- name: okd-installer | Destroy | Network | Loading Topology Names
Expand All @@ -45,35 +44,30 @@
ansible.builtin.include_vars:
file: "{{ profile_path }}/loadbalancer-router-default.yaml"

- name: okd-installer | Destroy | LB | Merge list
- name: okd-installer | Destroy | LB | Merge
ansible.builtin.set_fact:
load_balancers_all: "{{ load_balancers_all + cloud_loadbalancers }}"
load_balancers_all: "{{ (load_balancers_all | d([])) + (cloud_loadbalancers | d([])) }}"

- name: okd-installer | Destroy | LB | Load API Names
ansible.builtin.include_vars:
file: "{{ profile_path }}/loadbalancer.yaml"

- name: okd-installer | Destroy | LB | Merge list
- name: okd-installer | Destroy | LB | Merge
ansible.builtin.set_fact:
load_balancers_all: "{{ load_balancers_all + cloud_loadbalancers }}"
load_balancers_all: "{{ load_balancers_all + (cloud_loadbalancers | d([])) }}"

- name: okd-installer | Destroy | LB | Consolidate
ansible.builtin.set_fact:
cloud_loadbalancers: "{{ load_balancers_all }}"

- name: okd-installer | Destroy | LB | Show number of resources
- name: okd-installer | Destroy | LB | Show resource count
ansible.builtin.debug:
msg: "Found {{ cloud_loadbalancers | length }} Load Balancers on the Configuration"

roles:
- role: destroy


- name: okd-installer | Destroy | Finish
hosts: '{{ target|default("localhost") }}'
connection: local
gather_facts: true
tasks:
post_tasks:
- name: okd-installer | Destroy | Finish | Timer end
ansible.builtin.set_fact:
okdi_del_timer_end: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}"
Expand All @@ -82,4 +76,4 @@
ansible.builtin.debug:
msg:
- "start=[{{ okdi_del_timer_start | d('') }}] end=[{{ okdi_del_timer_end }}]"
- "total=[{{ ((okdi_del_timer_end | to_datetime) - (okdi_del_timer_start | to_datetime)) }}]"
- "total=[{{ ((okdi_del_timer_end | to_datetime) - (okdi_del_timer_start | to_datetime)) }}]"
3 changes: 2 additions & 1 deletion playbooks/group_vars/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ collection_cluster_dir: "{{ bindir | d(collection_work_dir + '/clusters') }}"

config_install_dir: "{{ collection_cluster_dir }}/{{ cluster_name }}"
bin_openshift_install: "{{ collection_bin_dir }}/openshift-install"
bin_oc: "{{ collection_bin_dir }}/openshift-install"
bin_oc: "{{ collection_bin_dir }}/oc"
bin_butane: "{{ collection_bin_dir }}/butane"

## export CONFIG_PULL_SECRET_FILE=${HOME}/.openshift/pull-secret-latest.jso
config_pull_secret_file: "{{ lookup('ansible.builtin.env', 'CONFIG_PULL_SECRET_FILE') }}"
Expand Down
12 changes: 12 additions & 0 deletions playbooks/os_mirror.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: okd-installer | Create Stack | Compute | Load Config
ansible.builtin.import_playbook: config.yaml
vars:
mode: load

- name: okd-installer | OS Mirror
hosts: localhost
connection: local

roles:
- os_mirror
21 changes: 14 additions & 7 deletions playbooks/stack_loadbalancer.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
# - ansible.builtin.import_playbook: var_check_required.yaml

- name: okd-installer | Stack | Load Balancer | Config load
ansible.builtin.import_playbook: config.yaml
Expand All @@ -9,6 +10,7 @@
hosts: '{{target|default("localhost")}}'
connection: local
vars:
cloud_loadbalancers_state: []
profile_path: "{{ playbook_dir }}/vars/{{ config_provider }}/profiles/{{ cluster_profile|d('default') }}"

pre_tasks:
Expand All @@ -22,11 +24,16 @@
file: "{{ profile_path }}/loadbalancer.yaml"
when: var_file is not defined

roles:
- cloud_load_balancer
- name: okd-installer | Stack | LB | setup
ansible.builtin.include_role:
name: cloud_load_balancer

- name: okd-installer | Stack | LB | Save state
ansible.builtin.import_playbook: config.yaml
vars:
mode: save-state
cluster_state: "{{ cluster_state | combine({'load_balancers': cloud_load_balancers_state}) }}"
- name: okd-installer | Stack | LB | update cluster_state
ansible.builtin.set_fact:
cluster_state: "{{ cluster_state | combine({'loadbalancers': cloud_loadbalancers_state}) }}"

- name: okd-installer | Stack | LB | save cluster_state
ansible.builtin.include_role:
name: config
vars:
mode: save-state
4 changes: 2 additions & 2 deletions playbooks/templates/ocp-bootstrap-user-data.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"ignition": {
"config": {
"replace": {
"source": "{{ openshift_userdata.config_source }}"
"source": "{{ userdata_config_source }}"
}
},
"version": "3.1.0"
}
}
}
4 changes: 2 additions & 2 deletions playbooks/templates/ocp-nodes-user-data.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"config": {
"merge": [
{
"source": "{{ openshift_userdata.config_source }}"
"source": "{{ userdata_config_source }}"
}
]
},
"security": {
"tls": {
"certificateAuthorities": [
{
"source": "{{ openshift_userdata.ca_source }}"
"source": "{{ userdata_config_ca_source }}"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ openshift_security_groups:
- "{{ openshift_prefix }}-controlplane-sg"
openshift_tags: "{{ cluster_state.tags }}"

openshift_userdata:
config_source: "s3://{{ openshift_bootstrap_bucket }}/bootstrap.ign"
userdata_config_source: "s3://{{ openshift_bootstrap_bucket }}/bootstrap.ign"

_def:
name: "{{ openshift_prefix }}-bootstrap"
Expand Down
14 changes: 7 additions & 7 deletions playbooks/vars/aws/profiles/HighlyAvailable/node-compute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ openshift_security_groups:
openshift_tags: "{{ cluster_state.tags }}"

# User Data template
openshift_userdata_template: ocp-nodes-user-data.j2
openshift_userdata:
config_source: "https://api-int.{{ cluster_state.dns.cluster_domain }}:22623/config/worker"
ca_source: "{{ cluster_state.certificates.root_ca }}"
_userdata_path: "{{ config_install_dir }}/worker.ign"
# _userdata_template: ocp-nodes-user-data.j2
# userdata_config_source: "https://api-int.{{ cluster_state.dns.cluster_domain }}:22623/config/worker"
# userdata_config_ca_source: "{{ cluster_state.certificates.root_ca }}"

_def:
name: 'worker'
Expand Down Expand Up @@ -55,7 +55,7 @@ compute_resources:
security_groups: "{{ _def.security_groups }}"
state: "{{ _def.state }}"
termination_protection: "{{ _def.termination_protection }}"
user_data: "{{ lookup('template', openshift_userdata_template) | to_nice_json | string }}"
user_data: "{{ lookup('file', _userdata_path) | b64encode }}"
volumes: "{{ _def.volumes | d([]) }}"
wait: no

Expand All @@ -74,7 +74,7 @@ compute_resources:
security_groups: "{{ _def.security_groups }}"
state: "{{ _def.state }}"
termination_protection: "{{ _def.termination_protection }}"
user_data: "{{ lookup('template', openshift_userdata_template) | to_nice_json | string }}"
user_data: "{{ lookup('file', _userdata_path) | b64encode }}"
volumes: "{{ _def.volumes | d([]) }}"
wait: no

Expand All @@ -93,6 +93,6 @@ compute_resources:
security_groups: "{{ _def.security_groups }}"
state: "{{ _def.state }}"
termination_protection: "{{ _def.termination_protection }}"
user_data: "{{ lookup('template', openshift_userdata_template) | to_nice_json | string }}"
user_data: "{{ lookup('file', _userdata_path) | b64encode }}"
volumes: "{{ _def.volumes | d([]) }}"
wait: yes
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ openshift_security_groups:
openshift_tags: "{{ cluster_state.tags }}"

# User Data template
openshift_userdata_template: ocp-nodes-user-data.j2
openshift_userdata:
config_source: "https://api-int.{{ cluster_state.dns.cluster_domain }}:22623/config/master"
ca_source: "{{ cluster_state.certificates.root_ca }}"
_userdata_path: "{{ config_install_dir }}/master.ign"
# userdata_template: ocp-nodes-user-data.j2
# userdata_config_source: "https://api-int.{{ cluster_state.dns.cluster_domain }}:22623/config/master"
# userdata_config_ca_source: "{{ cluster_state.certificates.root_ca }}"

_def:
name: 'master'
Expand Down Expand Up @@ -54,7 +54,7 @@ compute_resources:
security_groups: "{{ _def.security_groups }}"
state: "{{ _def.state }}"
termination_protection: "{{ _def.termination_protection }}"
user_data: "{{ lookup('template', openshift_userdata_template) | to_nice_json | string }}"
user_data: "{{ lookup('file', _userdata_path) | b64encode }}"
volumes: "{{ _def.volumes | d([]) }}"
wait: no

Expand Down Expand Up @@ -91,7 +91,7 @@ compute_resources:
security_groups: "{{ _def.security_groups }}"
state: "{{ _def.state }}"
termination_protection: "{{ _def.termination_protection }}"
user_data: "{{ lookup('template', openshift_userdata_template) | to_nice_json | string }}"
user_data: "{{ lookup('file', _userdata_path) | b64encode }}"
volumes: "{{ _def.volumes | d([]) }}"
wait: no

Expand Down Expand Up @@ -128,7 +128,7 @@ compute_resources:
security_groups: "{{ _def.security_groups }}"
state: "{{ _def.state }}"
termination_protection: "{{ _def.termination_protection }}"
user_data: "{{ lookup('template', openshift_userdata_template) | to_nice_json | string }}"
user_data: "{{ lookup('file', _userdata_path) | b64encode }}"
volumes: "{{ _def.volumes | d([]) }}"
wait: no

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ _image_id: "{{ custom_image_id | d(cluster_state.compute.image_id) }}"
_subnet_name: "{{ _cluster_prefix }}-net-public-1a"

## User Data template
openshift_userdata:
config_source: "s3://{{ bootstrap_bucket }}/bootstrap.ign"
userdata_config_source: "s3://{{ bootstrap_bucket }}/bootstrap.ign"

## Common vars used in the Stack vars
_common:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ _tags: "{{ cluster_state.tags }}"

## User Data template
_userdata_template: ocp-nodes-user-data.j2
openshift_userdata:
config_source: "https://api-int.{{ cluster_state.dns.cluster_domain }}:22623/config/master"
ca_source: "{{ cluster_state.certificates.root_ca }}"
userdata_config_source: "https://api-int.{{ cluster_state.dns.cluster_domain }}:22623/config/master"
userdata_config_ca_source: "{{ cluster_state.certificates.root_ca }}"

## Common vars used in the Stack vars
_common:
Expand Down
Loading

0 comments on commit 014c9b9

Please sign in to comment.