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

Fix/bastion host error #271

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1e0c38e
Made updates
Sep 13, 2022
01ade2a
Added local
Sep 13, 2022
86750d7
Added changes
Sep 13, 2022
18cba77
Added root access to bootstrap
Sep 15, 2022
1eb2fcc
Changed VLAN
Sep 20, 2022
05dec3e
Changed AZ
Sep 20, 2022
cb5d012
Reverted bootrap ignition
Sep 21, 2022
6388e04
Added back bootstrap access
Sep 22, 2022
535714f
change az to z15
Sep 22, 2022
13589e2
.
Sep 22, 2022
77557d4
Reveretd
Sep 22, 2022
920351b
Added changes
Sep 26, 2022
f517597
Updated IPs
Sep 26, 2022
c3930c6
Remove
Sep 26, 2022
616ba5f
Added back changes
Sep 29, 2022
6a86042
Added changes
Feb 1, 2023
2ef7c72
Resolved merge conflicts
Feb 9, 2023
bd9bdf2
Merge pull request #1 from frankmit11/kvmOcpUpcEnhancements
frankmit11 Feb 9, 2023
896473a
Added changes
Apr 19, 2023
85284ec
Resolved merge conflicts
Apr 19, 2023
d1238f0
Resolved merge conflicts
Apr 19, 2023
1e9a959
Merge branch 'main' of https://github.com/IBM/z_ansible_collections_s…
Apr 26, 2023
ee3c815
Merge branch 'main' of https://github.com/IBM/z_ansible_collections_s…
Jun 13, 2023
d4a96da
updated upi
Oct 20, 2023
12854e1
resolved merge conflicts
Nov 1, 2023
04da0dd
resolved merges
May 28, 2024
8ca002c
Merge branch 'main' of https://github.com/IBM/z_ansible_collections_s…
Jun 3, 2024
8255776
removed public key and setting of root pw
Jun 6, 2024
99a0ed4
Merge branch 'main' of https://github.com/IBM/z_ansible_collections_s…
Jul 3, 2024
9998ef1
added use of bastion validation for destroy and add new compute
Jul 3, 2024
275385b
Update generate-bootstrap-ignitionshim.py
frankmit11 Jul 3, 2024
f07ed7c
fix PR
Jul 3, 2024
21a4c36
Merge branch 'fix/bastion-host-error' of github.com:frankmit11/icic-o…
Jul 3, 2024
ee98407
Update main.yaml
frankmit11 Jul 3, 2024
b9da3f0
Update inventory.yaml
frankmit11 Jul 3, 2024
45822dd
fix PR
Jul 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- import_playbook: destroy-controls.yaml
- import_playbook: destroy-bootstrap.yaml
- import_playbook: destroy-computes.yaml
- import_playbook: cleanup-bastion.yaml
when: use_internal_bastion == true
- import_playbook: destroy-network.yaml
- import_playbook: destroy-security-groups.yaml
- import_playbook: destroy-volumes.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,52 +238,5 @@
workers_list: "{{ item.split(',') }}"
with_items: "{{ works_list_results.stdout_lines }}"

- hosts: bastion
tasks:
- name: 'Check whether use internal bastion'
set_fact:
use_internal_bastion: "{{ hostvars['localhost']['use_internal_bastion'] }}"

- name: 'Modify bastion dns for new worker'
ansible.builtin.include_tasks: modify-dns.yaml
vars:
worker_name: "{{ item.split(':')[0] }}"
worker_ip: "{{ item.split(':')[-1] }}"
cluster_domain_name: "{{ hostvars['localhost']['cluster_name'] }}.{{ hostvars['localhost']['base_domain'] }}"
with_items: "{{ hostvars['localhost']['workers_list'] }}"
when:
- use_internal_bastion == true

- name: 'Modify bastion haproxy for new worker'
ansible.builtin.include_tasks: modify-haproxy.yaml
vars:
worker_name: "{{ item.split(':')[0] }}"
cluster_domain_name: "{{ hostvars['localhost']['cluster_name'] }}.{{ hostvars['localhost']['base_domain'] }}"
with_items: "{{ hostvars['localhost']['workers_list'] }}"
when:
- use_internal_bastion == true

- name: Restart named-chroot.service
ansible.builtin.service:
name: named-chroot.service
state: restarted
when:
- use_internal_bastion == true

- name: Restart HAProxy.service
ansible.builtin.service:
name: haproxy.service
state: restarted
when:
- use_internal_bastion == true

- name: Check if named-chroot is running
ansible.builtin.service:
name: named-chroot
state: started

- name: Check if HAProxy is running
ansible.builtin.service:
name: haproxy
state: started

- import_playbook: update-bastion-new-compute.yaml
when: use_internal_bastion == true
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# =================================================================
# Copyright 2021 https://github.com/openshift/installer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =================================================================

# Required Python packages:
#
# ansible
# openstackclient
# openstacksdk

- hosts: bastion
tasks:
- name: 'Check whether use internal bastion'
set_fact:
use_internal_bastion: "{{ hostvars['localhost']['use_internal_bastion'] }}"

- name: 'Set fact of domain info'
set_fact:
cluster_domain_name: "{{ hostvars['localhost']['cluster_name'] }}.{{ hostvars['localhost']['base_domain'] }}"

- name: 'Validate master exits'
ansible.builtin.shell: |
count=$(grep -c 'master' /var/named/{{ cluster_domain_name }}.zone)
echo $count
register: master_exists_count

- name: 'Get the line number of the master'
ansible.builtin.shell: grep 'master' /var/named/{{ cluster_domain_name }}.zone
register: master_ln
when: master_exists_count.stdout | int > 0

- name: Remove /etc/haproxy/haproxy.cfg info with masters
ansible.builtin.shell: sed -i '/{{ item.split(' ')[0] }}/d' /etc/haproxy/haproxy.cfg
with_items: "{{ master_ln.stdout_lines }}"
when:
- master_exists_count.stdout | int > 0

- name: Remove bastion dns info with masters
ansible.builtin.shell: sed -i '/{{ item.split(' ')[0] }}/d' /var/named/{{ cluster_domain_name }}.zone
with_items: "{{ master_ln.stdout_lines }}"
when:
- master_exists_count.stdout | int > 0

- name: 'Validate worker exits'
ansible.builtin.shell: |
count=$(grep -c 'worker' /var/named/{{ cluster_domain_name }}.zone)
echo $count
register: worker_exist_count

- name: 'Get the line number of the worker'
ansible.builtin.shell: grep 'worker' /var/named/{{ cluster_domain_name }}.zone
register: worker_ln
when: worker_exist_count.stdout | int > 0

- name: Remove /etc/haproxy/haproxy.cfg info with workers
ansible.builtin.shell: sed -i '/{{ item.split(' ')[0] }}/d' /etc/haproxy/haproxy.cfg
with_items: "{{ worker_ln.stdout_lines }}"
when:
- worker_exist_count.stdout | int > 0

- name: Remove bastion dns info with workers
ansible.builtin.shell: sed -i '/{{ item.split(' ')[0] }}/d' /var/named/{{ cluster_domain_name }}.zone
with_items: "{{ worker_ln.stdout_lines }}"
when:
- worker_exist_count.stdout | int > 0
Original file line number Diff line number Diff line change
Expand Up @@ -61,38 +61,3 @@
ansible.builtin.shell:
cmd: "openstack server delete {{ item.1 }}"
with_indexed_items: "{{ computes.stdout_lines }}"

- hosts: bastion
tasks:
- name: 'Check whether use internal bastion'
set_fact:
use_internal_bastion: "{{ hostvars['localhost']['use_internal_bastion'] }}"

- name: 'Set fact of domain info'
set_fact:
cluster_domain_name: "{{ hostvars['localhost']['cluster_name'] }}.{{ hostvars['localhost']['base_domain'] }}"

- name: 'Validate worker exits'
ansible.builtin.shell: |
count=$(grep -c 'worker' /var/named/{{ cluster_domain_name }}.zone)
echo $count
register: worker_exist_count

- name: 'Get the line number of the worker'
ansible.builtin.shell: grep 'worker' /var/named/{{ cluster_domain_name }}.zone
register: worker_ln
when: worker_exist_count.stdout | int > 0

- name: Remove /etc/haproxy/haproxy.cfg info with workers
ansible.builtin.shell: sed -i '/{{ item.split(' ')[0] }}/d' /etc/haproxy/haproxy.cfg
with_items: "{{ worker_ln.stdout_lines }}"
when:
- worker_exist_count.stdout | int > 0
- use_internal_bastion == true

- name: Remove bastion dns info with workers
ansible.builtin.shell: sed -i '/{{ item.split(' ')[0] }}/d' /var/named/{{ cluster_domain_name }}.zone
with_items: "{{ worker_ln.stdout_lines }}"
when:
- worker_exist_count.stdout | int > 0
- use_internal_bastion == true
Original file line number Diff line number Diff line change
Expand Up @@ -53,38 +53,3 @@
cmd: "openstack --os-compute-api-version=2.15 server group delete {{ server_group_id }}"
when:
- server_group_id is defined

- hosts: bastion
tasks:
- name: 'Check whether use internal bastion'
set_fact:
use_internal_bastion: "{{ hostvars['localhost']['use_internal_bastion'] }}"

- name: 'Set fact of domain info'
set_fact:
cluster_domain_name: "{{ hostvars['localhost']['cluster_name'] }}.{{ hostvars['localhost']['base_domain'] }}"

- name: 'Validate master exits'
ansible.builtin.shell: |
count=$(grep -c 'master' /var/named/{{ cluster_domain_name }}.zone)
echo $count
register: master_exists_count

- name: 'Get the line number of the master'
ansible.builtin.shell: grep 'master' /var/named/{{ cluster_domain_name }}.zone
register: master_ln
when: master_exists_count.stdout | int > 0

- name: Remove /etc/haproxy/haproxy.cfg info with masters
ansible.builtin.shell: sed -i '/{{ item.split(' ')[0] }}/d' /etc/haproxy/haproxy.cfg
with_items: "{{ master_ln.stdout_lines }}"
when:
- master_exists_count.stdout | int > 0
- use_internal_bastion == true

- name: Remove bastion dns info with masters
ansible.builtin.shell: sed -i '/{{ item.split(' ')[0] }}/d' /var/named/{{ cluster_domain_name }}.zone
with_items: "{{ master_ln.stdout_lines }}"
when:
- master_exists_count.stdout | int > 0
- use_internal_bastion == true
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# =================================================================
# Licensed Materials - Property of IBM
#
# (c) Copyright IBM Corp. 2023 All Rights Reserved
#
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
# =================================================================

# Required Python packages:
#
# ansible
# openstackclient
# openstacksdk
# netaddr

- hosts: bastion
tasks:
- name: 'Check whether use internal bastion'
set_fact:
use_internal_bastion: "{{ hostvars['localhost']['use_internal_bastion'] }}"

- name: 'Modify bastion dns for new worker'
ansible.builtin.include_tasks: modify-dns.yaml
vars:
worker_name: "{{ item.split(':')[0] }}"
worker_ip: "{{ item.split(':')[-1] }}"
cluster_domain_name: "{{ hostvars['localhost']['cluster_name'] }}.{{ hostvars['localhost']['base_domain'] }}"
with_items: "{{ hostvars['localhost']['workers_list'] }}"
when:
- use_internal_bastion == true

- name: 'Modify bastion haproxy for new worker'
ansible.builtin.include_tasks: modify-haproxy.yaml
vars:
worker_name: "{{ item.split(':')[0] }}"
cluster_domain_name: "{{ hostvars['localhost']['cluster_name'] }}.{{ hostvars['localhost']['base_domain'] }}"
with_items: "{{ hostvars['localhost']['workers_list'] }}"
when:
- use_internal_bastion == true

- name: Restart named-chroot.service
ansible.builtin.service:
name: named-chroot.service
state: restarted
when:
- use_internal_bastion == true

- name: Restart HAProxy.service
ansible.builtin.service:
name: haproxy.service
state: restarted
when:
- use_internal_bastion == true

- name: Check if named-chroot is running
ansible.builtin.service:
name: named-chroot
state: started

- name: Check if HAProxy is running
ansible.builtin.service:
name: haproxy
state: started