Skip to content

Commit

Permalink
Apac summit (redhat-cop#5463)
Browse files Browse the repository at this point in the history
* aws-prod-a

* fixed venv
  • Loading branch information
miteshget authored Sep 23, 2022
1 parent a835c22 commit 7502275
Showing 1 changed file with 106 additions and 6 deletions.
112 changes: 106 additions & 6 deletions ansible/configs/summit-hybrid-cloud-binder/post_software.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
ansible_user: "ec2-user"
remote_user: "ec2-user"

- name: add aws_prod_a to inventory
ansible.builtin.add_host:
name: "{{ aws_prod_a_provision_data.bastion_public_hostname }}"
groups: ohc_aws_prod_a
ansible_connection: ssh
# ansible_ssh_extra_args: "{{ ansible_ssh_extra_args|d() }} -F {{output_dir}}/{{ env_type }}_{{ guid }}_ssh_conf"
ansible_ssh_private_key_file: "~/.ssh/opentlc_admin_backdoor.pem"
ansible_user: "ec2-user"
remote_user: "ec2-user"

- name: Logging into Hub
k8s_auth:
host: "{{ aws_hub_provision_data.openshift_api_url }}"
Expand Down Expand Up @@ -71,6 +81,18 @@
until:
- __r_aws_dev_a.k8s_auth.api_key is defined

- name: Logging into AWS OCP4 Prod A
k8s_auth:
host: "{{ aws_prod_a_provision_data.openshift_api_url }}"
username: "{{ aws_prod_a_provision_data.openshift_cluster_admin_username }}"
password: "{{ aws_prod_a_provision_data.openshift_cluster_admin_password }}"
validate_certs: false
register: __r_aws_prod_a
retries: 240
delay: 15
until:
- __r_aws_prod_a.k8s_auth.api_key is defined

- name: Import clusters into hub
when:
- hybrid_cloud_binder_import_clusters_enable is true
Expand All @@ -88,7 +110,8 @@
api_version: v1
loop:
- 'aws-dev-a'
- 'azure-dev-a'
- 'dc-dev-a'
- 'aws-prod-a'

- name: Import AWS OCP4 Cluster A to Hub
vars:
Expand Down Expand Up @@ -116,7 +139,7 @@

- name: Import Azure OCP4 Cluster A to Hub
vars:
__managed_cluster_name: 'azure-dev-a'
__managed_cluster_name: 'dc-dev-a'
__managed_cluster_token: "{{ __r_azure_dev_a.k8s_auth.api_key }}"
__managed_cluster_api_url: "{{ __r_azure_dev_a.k8s_auth.host }}"
k8s:
Expand All @@ -137,6 +160,29 @@
#until:
#- __r_import_azure_dev_a is defined

- name: Import AWS OCP4 Prod Cluster A to Hub
vars:
__managed_cluster_name: 'aws-prod-a'
__managed_cluster_token: "{{ __r_aws_prod_a.k8s_auth.api_key }}"
__managed_cluster_api_url: "{{ __r_aws_prod_a.k8s_auth.host }}"
k8s:
host: "{{ __r_hub.k8s_auth.host }}"
username: "{{ __r_hub.k8s_auth.username }}"
api_key: "{{ __r_hub.k8s_auth.api_key }}"
validate_certs: false
state: present
definition: "{{ lookup('template', item ) | from_yaml }}"
loop:
- './templates/managed-cluster.yaml.j2'
- './templates/auto-import-secret.yaml.j2'
- './templates/klusterlet-addon-config.yaml.j2'
register: __r_import_aws_prod_a
retries: 240
delay: 15
# TODO: need a better test
#until:
#- __r_import_aws_prod_a is defined

- name: Validate Clusters Joined - aws-dev-a
k8s_info:
host: "{{ __r_hub.k8s_auth.host }}"
Expand All @@ -159,7 +205,7 @@
- ( __r_wait_aws_dev_a.resources[0].status | to_json | from_json |
json_query('conditions[?type == `ManagedClusterConditionAvailable`].status') | join ) == "True"

- name: Validate Clusters Joined - azure-dev-a
- name: Validate Clusters Joined - dc-dev-a
ignore_errors: true
k8s_info:
host: "{{ __r_hub.k8s_auth.host }}"
Expand All @@ -168,8 +214,8 @@
validate_certs: false
api_version: cluster.open-cluster-management.io/v1
kind: managedcluster
name: azure-dev-a
namespace: azure-dev-a
name: dc-dev-a
namespace: dc-dev-a
register: __r_wait_azure_dev_a
retries: 240
delay: 15
Expand All @@ -181,18 +227,72 @@
- ( __r_wait_azure_dev_a.resources[0].status | to_json | from_json |
json_query('conditions[?type == `ManagedClusterConditionAvailable`].status') | join ) == "True"

- name: Validate Clusters Joined - aws-prod-a
k8s_info:
host: "{{ __r_hub.k8s_auth.host }}"
username: "{{ __r_hub.k8s_auth.username }}"
api_key: "{{ __r_hub.k8s_auth.api_key }}"
validate_certs: false
api_version: cluster.open-cluster-management.io/v1
kind: managedcluster
name: aws-prod-a
namespace: aws-prod-a
register: __r_wait_aws_prod_a
ignore_errors: true
retries: 240
delay: 15
until:
- __r_wait_aws_prod_a.resources is defined
- __r_wait_aws_prod_a.resources | length | int > 0
- __r_wait_aws_prod_a.resources[0].status is defined
- __r_wait_aws_prod_a.resources[0].status.conditions is defined
- ( __r_wait_aws_prod_a.resources[0].status | to_json | from_json |
json_query('conditions[?type == `ManagedClusterConditionAvailable`].status') | join ) == "True"

- name: Print aws-prod-a info
agnosticd_user_info:
data:
aws_prod_a_cluster_name: 'aws-prod-a'
aws_prod_a_cluster_token: "{{ __r_aws_prod_a.k8s_auth.api_key }}"
aws_prod_a_cluster_api_url: "{{ __r_aws_prod_a.k8s_auth.host }}"
msg: |
aws_prod_a_cluster_name: aws-prod-a
aws_prod_a_cluster_token: {{ __r_aws_prod_a.k8s_auth.api_key }}
aws_prod_a_cluster_api_url: {{ __r_aws_prod_a.k8s_auth.host }}
- name: Step 005 Post Software - Cloud name
hosts: ohc_hub
gather_facts: false
environment:
KUBECONFIG: /home/{{ ansible_user }}/.kube/config
tasks:

- name: Change local-cloud to vmware
command: >-
oc patch ManagedCluster local-cluster
-p='[{"op": "replace", "path": "/metadata/labels/cloud", "value":"vmware"}]'
-n open-cluster-management
--type json
- name: Change dc-dev-a to baremetal
command: >-
oc patch ManagedCluster dc-dev-a
-p='[{"op": "replace", "path": "/metadata/labels/cloud", "value":"baremetal"}]'
-n open-cluster-management
--type json
- name: Set Ansible Python interpreter to k8s virtualenv
set_fact:
ansible_python_interpreter: /opt/virtualenvs/k8s/bin/python

- name: Remove aws-prod-a cluster
k8s:
api_version: "cluster.open-cluster-management.io/v1"
kind: ManagedCluster
name: aws-prod-a
namespace: open-cluster-management
state: absent


- name: Step 005 Post Software - Report to Cloudforms
hosts: localhost
connection: local
Expand Down

0 comments on commit 7502275

Please sign in to comment.