Skip to content

Commit

Permalink
playbook to init the jump server
Browse files Browse the repository at this point in the history
Downloads the CLI and extracts the cluster installation folder
  • Loading branch information
jacobdotcosta committed Nov 22, 2023
1 parent 5fd021c commit 5af6d9e
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 76 deletions.
59 changes: 58 additions & 1 deletion ansible/playbook/ocp/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ To collect information on the OCP cluster execute the
`ocp_openstack_info` playbook located at the `ansible/playbook/ocp/`
folder.


.Playbook parameters
[%header,cols="25%,75%"]
|===
Expand Down Expand Up @@ -333,3 +332,61 @@ ansible-playbook ansible/playbook/ocp/ocp_openstack_info.yml \
-e vm_name=ocp-sdev-zzzzz-jump-server -vv
----

=== Init jump server

This playbook init's a jump server by performing the following tasks:

* Downloads the OCP and k8s CLI binaries into the jump server
* Copy the OCP cluster installation folder from passwordstore
into the jump server.

.Playbook parameters
[%header,cols="25%,75%"]
|===
| Variable | Description

| `ocp_root_directory`

[.fuchsia]#string# / [.red]#required#

a| Root folder for the OCP installation.

Either define the `ocp_root_directory` and `ocp_cluster_name` variables
or the `installation_dir` one.

| `ocp_cluster_name`

[.fuchsia]#string# / [.red]#required#

a| Name of the OCP cluster

Either define the `ocp_root_directory` and `ocp_cluster_name` variables
or the `installation_dir` one.

| `ocp_cluster_bin_directory`

[.fuchsia]#string#

a| Folder that will contain the OCP and k8s CLI binaries

*Default => `<ocp_root_directory>/bin`*

| `vm_name`

[.fuchsia]#string# / [.red]#required#

a| Root folder where for the installation. A new sub-folder with the
`ocp_cluster_name` name will be created and will serve as the
installation folder.

|===

[source,bash]
----
ansible-playbook ansible/playbook/ocp/rhosp_init_jump_server_pass.yml \
-e ocp_root_directory=/home/snowdrop/ocp \
-e ocp_cluster_name=ocp-sdev \
-e vm_name=ocp-jump-server \
-e ocp_cluster_bin_directory=/home/snowdrop/.local/bin \
-vv
----
75 changes: 0 additions & 75 deletions ansible/playbook/ocp/ocp_openstack_init_jump_servery.yml

This file was deleted.

97 changes: 97 additions & 0 deletions ansible/playbook/ocp/rhosp_init_jump_server_pass.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
# Requires:
# vars:
# tmp_directory: temporary directory =/opt/ocp/_tmp/ansible.yxam0y7mbuild
# ocp_root_directory: /opt/ocp
# ocp_cluster_name: ocp-sdev
# vm_name: ocp-sdev-p75fs-jump-server
- name: "Build OpenStack authentication for v3password"
ansible.builtin.import_playbook: "../openstack/openstack_auth_passstore_v3password.yml"

- name: "Create directory structure"
hosts: "{{ vm_name | default([]) }}"
gather_facts: true
vars:
remote_bin_folder: /home/snowdrop/.local/bin

tasks:
# - name: Create home .local/bin folder
# ansible.builtin.file:
# path: "{{ remote_bin_folder }}"
# recurse: true
# state: directory
# owner: "{{ ansible_user_id }}"
# group: "{{ ansible_user_id }}"
# mode: '0755'

# - name: Copy installation folder to remote host
# ansible.builtin.copy:
# src: /tmp/ocp-installation.tgz
# dest: /tmp/ocp-installation.tgz

# - name: Extract OCP installation into /home/snowdrop
# ansible.builtin.unarchive:
# src: /tmp/ocp-installation.tgz
# dest: /home/snowdrop

- name: Download OCP files
ansible.builtin.import_role:
name: ocp_cluster
tasks_from: install_prepare.yml
vars:
state: absent
# ocp_bin_directory: "{{ remote_bin_folder }}"

- name: Download OCP files
ansible.builtin.import_role:
name: ocp_cluster
tasks_from: download_installation_files.yml
# vars:
# ocp_cluster_bin_directory: "{{ remote_bin_folder }}"

- name: "Extract installation directory from passwordstore"
hosts: "localhost"
gather_facts: false

tasks:

- name: "Extract installation directory from passwordstore"
ansible.builtin.copy:
content: "{{ query('passwordstore', 'openstack/' + ocp_cluster_name + '/install_dir')[0] | b64decode }}"
dest: /tmp/ocp-installation-{{ ocp_cluster_name }}.tgz
when: ocp_bootstrap_host is not defined

- name: "Extract installation directory from passwordstore"
ansible.builtin.copy:
content: "{{ query('passwordstore', 'openstack/' + ocp_bootstrap_host + '/install_dir')[0] | b64decode }}"
dest: /tmp/ocp-installation-{{ ocp_cluster_name }}.tgz
when: ocp_bootstrap_host is defined

- name: "Expand installation directory on Jump Server"
hosts: "{{ vm_name | default([]) }}"
gather_facts: true
vars:
remote_bin_folder: /home/snowdrop/.local/bin

tasks:

- name: Copy installation folder to remote host
ansible.builtin.copy:
src: /tmp/ocp-installation-{{ ocp_cluster_name }}.tgz
dest: /tmp/ocp-installation-{{ ocp_cluster_name }}.tgz

- name: "Create OCP cluster directory"
ansible.builtin.file:
path: "{{ ocp_root_directory }}/{{ ocp_cluster_name }}"
state: directory
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_id }}"
mode: '0755'

- name: Extract OCP installation into /home/snowdrop
ansible.builtin.unarchive:
src: /tmp/ocp-installation-{{ ocp_cluster_name }}.tgz
dest: "{{ ocp_root_directory }}/{{ ocp_cluster_name }}"

...

0 comments on commit 5af6d9e

Please sign in to comment.