From 5c56cfc9aa97a54784c05aea92948ecd04a3ded0 Mon Sep 17 00:00:00 2001 From: Amadeuds Podvratnik Date: Mon, 9 Sep 2024 11:39:37 +0200 Subject: [PATCH] Make pkgs vars default (#326) Remove packages (env.pkgs.) from all.yaml.template and use defaults instead. --------- Signed-off-by: Amadeuds Podvratnik Signed-off-by: K Shiva Sai Signed-off-by: Da Li Liu Signed-off-by: veera-damisetti Signed-off-by: Klaus Smolin Signed-off-by: Sanidhya Signed-off-by: mmondics Signed-off-by: Sumit Solanki Signed-off-by: DAMISETTI-VEERABHADRARAO Signed-off-by: Sanjay Yadav Co-authored-by: k-shiva-sai <73527143+k-shiva-sai@users.noreply.github.com> Co-authored-by: K Shiva Sai Co-authored-by: liudali Co-authored-by: Veerabhadrarao Damisetti Co-authored-by: Klaus Smolin <88041391+smolin-de@users.noreply.github.com> Co-authored-by: Sanidhya Co-authored-by: Sanidhya Co-authored-by: mmondics <46940343+mmondics@users.noreply.github.com> Co-authored-by: Sumit Solanki Co-authored-by: Sumit Solanki Co-authored-by: sanjayy-ibm Co-authored-by: Sanjay Yadav --- docs/set-variables-group-vars.md | 34 +++++++++++-------- .../default/group_vars/all.yaml.template | 26 ++++++-------- playbooks/0_setup.yaml | 8 ++--- playbooks/3_setup_kvm_host.yaml | 2 +- playbooks/5_setup_bastion.yaml | 2 +- roles/install_galaxy/defaults/main.yaml | 2 ++ roles/install_galaxy/tasks/main.yaml | 9 +++++ roles/install_packages/defaults/main.yaml | 4 +++ roles/install_packages/tasks/main.yaml | 7 ++-- .../install_tessia_baselib/defaults/main.yaml | 2 ++ roles/install_tessia_baselib/tasks/main.yaml | 2 +- 11 files changed, 55 insertions(+), 43 deletions(-) create mode 100644 roles/install_galaxy/defaults/main.yaml create mode 100644 roles/install_galaxy/tasks/main.yaml create mode 100644 roles/install_packages/defaults/main.yaml create mode 100644 roles/install_tessia_baselib/defaults/main.yaml diff --git a/docs/set-variables-group-vars.md b/docs/set-variables-group-vars.md index acc254f9..ea8e58da 100644 --- a/docs/set-variables-group-vars.md +++ b/docs/set-variables-group-vars.md @@ -148,15 +148,7 @@ **env.cluster.nodes.infra.ipv6** | (Optional) IPv6 address of the infra nodes. iThis list can be expanded to any number of nodes, minimum 2. Use provided list formatting (if use_ipv6 variable is 'True'). | fd00::10fd00::11 **env.cluster.nodes.infra.hostname** | (Optional) Hostnames for infra nodes. Must match the total number of IP addresses for infra nodes. If DNS is hosted on the bastion, this can be anything. If DNS is hosted elsewhere, this must match DNS definition. This will be combined with the metadata_name and base_domain to create a Fully Qualififed Domain Name (FQDN). | infra-01infra-02 -## 11 - (Optional) Packages -**Variable Name** | **Description** | **Example** -:--- | :--- | :--- -**env.pkgs.galaxy** | A list of Ansible Galaxy collections that will be installed during the setup playbook. The collections listed are required. Feel free to add more as needed, just make sure to follow the same list format. | community.general -**env.pkgs.controller** | A list of packages that will be installed on the machine running Ansible during the setup playbook. Feel free to add more as needed, just make sure to follow the same list format. | openssh -**env.pkgs.kvm** | A list of packages that will be installed on the KVM Host during the setup_kvm_host playbook. Feel free to add more as needed, just make sure to follow the same list format. | qemu-kvm -**env.pkgs.bastion** | A list of packages that will be installed on the bastion during the setup_bastion playbook. Feel free to add more as needed, just make sure to follow the same list format. | haproxy - -## 12 - OpenShift Settings +## 11 - OpenShift Settings **Variable Name** | **Description** | **Example** :--- | :--- | :--- **env.install_config.api_version** | Kubernetes API version for the cluster. These install_config variables will be passed to the OCP install_config file. This file is templated in the get_ocp role during the setup_bastion playbook. To make more fine-tuned adjustments to the install_config, you can find it at roles/get_ocp/templates/install-config.yaml.j2 | v1 @@ -171,14 +163,14 @@ **env.install_config.machine_network** | The IP address block for Nodes IP Pool. The default value is 192.168.122.0/24 For NAT Network Mode. In case of MacvTap it will be depend on Inteface IP assignment. An array with an IP address block in CIDR format. | 192.168.122.0/24 **env.install_config.fips** | True or False (boolean) for whether or not to use the United States' Federal Information Processing Standards (FIPS). Not yet certified on IBM zSystems. Enclosed in 'single quotes'. | 'false' -## 13 - (Optional) Proxy +## 12 - (Optional) Proxy **Variable Name** | **Description** | **Example** :--- | :--- | :--- **env.proxy.http** | (Optional) A proxy URL to use for creating HTTP connections outside the cluster. Will be used in the install-config and applied to other Ansible hosts unless set otherwise in no_proxy below. Must follow this pattern: http://username:pswd>@ip:port | http://ocp-admin:Pa$sw0rd@9.72.10.1:80 **env.proxy.https** | (Optional) A proxy URL to use for creating HTTPS connections outside the cluster. Will be used in the install-config and applied to other Ansible hosts unless set otherwise in no_proxy below. Must follow this pattern: https://username:pswd@ip:port | https://ocp-admin:Pa$sw0rd@9.72.10.1:80 **env.proxy.no** | (Optional) A comma-separated list (no spaces) of destination domain names, IP addresses, or other network CIDRs to exclude from proxying. When using a proxy, all necessary IPs and domains for your cluster will be added automatically. See roles/get_ocp/templates/install-config.yaml.j2 for more details on the template. Preface a domain with . to match subdomains only. For example, .y.com matches x.y.com, but not y.com. Use * to bypass the proxy for all listed destinations. | example.com,192.168.10.1 -## 14 - (Optional) Misc +## 13 - (Optional) Misc **Variable Name** | **Description** | **Example** :--- | :--- | :--- **env.language** | What language would you like Red Hat Enterprise Linux to use? In UTF-8 language code. Available languages and their corresponding codes can be found [here](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html-single/international_language_support_guide/index), in the "Locale" column of Table 2.1. | en_US.UTF-8 @@ -196,7 +188,7 @@ **env.jumphost.pass** | (Optional) The password for user to login to the jumphost. | ch4ngeMe! **env.jumphost.path_to_keypair** | (Optional) The absolute path to the public key file on the jumphost to be copied to the bastion. | /home/admin/.ssh/id_rsa.pub -## 15 - OCP and RHCOS (CoreOS) +## 14 - OCP and RHCOS (CoreOS) **Variable Name** | **Description** | **Example** :--- | :--- | :--- @@ -209,7 +201,7 @@ **rhcos_live_initrd** | CoreOS initramfs to be used for the bootstrap, control and compute nodes. | rhcos-4.12.3-s390x-live-initramfs.s390x.img **rhcos_live_rootfs** | CoreOS rootfs to be used for the bootstrap, control and compute nodes. | rhcos-4.12.3-s390x-live-rootfs.s390x.img -## 16 - (Optional) Create compute node in a day-2 operation +## 15 - (Optional) Create compute node in a day-2 operation **Variable Name** | **Description** | **Example** :--- | :--- | :--- @@ -223,8 +215,7 @@ **day2_compute_node.host_user** | KVM host user which is used to create the VM | root **day2_compute_node.host_arch** | KVM host architecture. | s390x -## 17 - (Optional) Agent Based Installer - +## 16 - (Optional) Agent Based Installer **Variable Name** | **Description** | **Example** :--- | :--- | :--- **abi.flag** | This is the flag, Will be used to identify during execution. Few checks in the playbook will be depend on this (default value will be False) | True @@ -232,6 +223,19 @@ **abi.ocp_installer_version** | Version will contain value of openshift-installer binary version user desired to be used | '4.15.0-rc.8' **abi.ocp_installer_url** | This is the base url of openshift installer binary it will remain same as static value, User Do not need to give value until user wants to change the mirror | 'https://mirror.openshift.com/pub/openshift-v4/s390x/clients/ocp/' +## Packages (Optional) +* Packages are installed based on the executed playbooks based on the given requirements. This means that these variables have default values which can be overwritten in all.yaml file. +* The following table describe the current installed packages and their default values. +* In general is to say that the default values are all required. Feel free to add more if needed but it is required to specify the whole list (include default values). +* Within the all.yaml.template file you find an example of the parameter including the format. + +**Variable Name** | **Description** | **Default values** +:--- | :--- | :--- +**pkgs_galaxy** | A list of Ansible Galaxy collections that will be installed during the setup playbook. The collections listed are required. | [ ibm.ibm_zhmc, community.general, community.crypto, ansible.posix, community.libvirt ] +**pkgs_controller** | A list of packages that will be installed on the machine running Ansible during the setup playbook. | [ openssh, expect, sshuttle ] +**pkgs_kvm** | A list of packages that will be installed on the KVM Host during the setup_kvm_host playbook. | [ libguestfs, libvirt-client, libvirt-daemon-config-network, libvirt-daemon-kvm, cockpit-machines, libvirt-devel, virt-top, qemu-kvm, python3-lxml, cockpit, lvm2 ] +**pkgs_bastion** | A list of packages that will be installed on the bastion during the setup_bastion playbook. Feel free to add more as needed, just make sure to follow the same list format. | [ haproxy, httpd, bind, bind-utils, expect, firewalld, mod_ssl, python3-policycoreutils, rsync ] +**pkgs_zvm** | A list of packages that will be installed in case of HCP (zVM nodes) or LPAR installation. | [ git, python3-pip, python3-devel, openssl-devel, rust, cargo, libffi-devel, wget, tar, jq, gcc, make, x3270, python39 ] ## Disconnected cluster setup (Optional) **Variable Name** | **Description** | **Example** diff --git a/inventories/default/group_vars/all.yaml.template b/inventories/default/group_vars/all.yaml.template index ce97490e..6861c0fb 100644 --- a/inventories/default/group_vars/all.yaml.template +++ b/inventories/default/group_vars/all.yaml.template @@ -187,15 +187,7 @@ env: # All variables below this point do not need to be changed for a default installation # ####################################################################################### -# Section 11 - (Optional) Packages - pkgs: - galaxy: [ ibm.ibm_zhmc, community.general, community.crypto, ansible.posix, community.libvirt ] - controller: [ openssh, expect, sshuttle ] - kvm: [ libguestfs, libvirt-client, libvirt-daemon-config-network, libvirt-daemon-kvm, cockpit-machines, libvirt-devel, virt-top, qemu-kvm, python3-lxml, cockpit, lvm2 ] - bastion: [ haproxy, httpd, bind, bind-utils, expect, firewalld, mod_ssl, python3-policycoreutils, rsync ] - zvm: [ git, python3-pip, python3-devel, openssl-devel, rust, cargo, libffi-devel, wget, tar, jq, gcc, make, x3270, python39 ] - -# Section 12 - OpenShift Settings +# Section 11 - OpenShift Settings install_config: api_version: v1 compute: @@ -212,13 +204,13 @@ env: machine_network: 192.168.122.0/24 fips: 'false' -# Section 13 - (Optional) Proxy +# Section 12 - (Optional) Proxy # proxy: # http: # https: # no: -# Section 14 - (Optional) Misc +# Section 13 - (Optional) Misc language: en_US.UTF-8 timezone: America/New_York keyboard: us @@ -239,7 +231,7 @@ env: pass: path_to_keypair: -# Section 15 - OCP and RHCOS (CoreOS) +# Section 14 - OCP and RHCOS (CoreOS) # ocp_download_url with '/' at the end ! ocp_download_url: "https://mirror.openshift.com/pub/openshift-v4/multi/clients/ocp/4.13.1/s390x/" @@ -259,8 +251,7 @@ rhcos_live_initrd: "rhcos-4.12.3-s390x-live-initramfs.s390x.img" rhcos_live_rootfs: "rhcos-4.12.3-s390x-live-rootfs.s390x.img" -# Section 16 - (Optional) Create additional compute node in a day-2 operation - +# Section 15 - (Optional) Create additional compute node in a day-2 operation day2_compute_node: vm_name: vm_hostname: @@ -273,10 +264,15 @@ day2_compute_node: host_arch: -# Section 17 - Agent Based Installer ( Optional ) +# Section 16 - Agent Based Installer ( Optional ) abi: flag: False ansible_workdir: 'ansible_workdir' ocp_installer_version: '4.15.0-rc.8' ocp_installer_url: 'https://mirror.openshift.com/pub/openshift-v4/s390x/clients/ocp/' boot_method: + +# (Optional) Packages +# Format to overwrite the packages to be installed is: +# pkgs_controller: [ openssh, expect, sshuttle ] +# Overwrite exists for pkgs_galaxy, pkgs_controller, pkgs_kvm, pkgs_bastion, pkgs_zvm diff --git a/playbooks/0_setup.yaml b/playbooks/0_setup.yaml index ba42957e..54bf91dd 100644 --- a/playbooks/0_setup.yaml +++ b/playbooks/0_setup.yaml @@ -9,6 +9,7 @@ - "{{ inventory_dir }}/group_vars/disconnected.yaml" roles: - set_inventory + - install_galaxy pre_tasks: - name: Check disconnected variables if disconnected cluster will be installed. @@ -18,11 +19,6 @@ when: disconnected.enabled post_tasks: - - name: Ensure Ansible Galaxy collections have been installed with latest version. - tags: galaxy - command: ansible-galaxy collection install {{ item }} --upgrade - loop: "{{ env.pkgs.galaxy }}" - - name: Find ibm_zhmc collection install location, if automated LPAR creation is to be used. tags: galaxy shell: ansible-galaxy collection list ibm.ibm_zhmc | grep -i ansible | cut -c 3- @@ -68,7 +64,7 @@ vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" vars: - packages: "{{ env.pkgs.controller }}" + packages: "pkgs_controller" ssh_target: [ "{{ env.file_server.ip }}", "{{ env.file_server.user }}", "{{ env.file_server.pass }}", "{{ path_to_key_pair }}" ] roles: - install_packages diff --git a/playbooks/3_setup_kvm_host.yaml b/playbooks/3_setup_kvm_host.yaml index ce3da1e1..97bb855b 100644 --- a/playbooks/3_setup_kvm_host.yaml +++ b/playbooks/3_setup_kvm_host.yaml @@ -69,7 +69,7 @@ gather_facts: true become: true vars: - packages: "{{ env.pkgs.kvm }}" + packages: "pkgs_kvm" roles: - { role: attach_subscription, when: env.redhat.manage_subscription } - install_packages diff --git a/playbooks/5_setup_bastion.yaml b/playbooks/5_setup_bastion.yaml index 847fcb75..f747fa35 100644 --- a/playbooks/5_setup_bastion.yaml +++ b/playbooks/5_setup_bastion.yaml @@ -71,7 +71,7 @@ tags: services, section_2 become: true vars: - packages: "{{ env.pkgs.bastion }}" + packages: "pkgs_bastion" control_node_count: "{{ env.cluster.nodes.control.ip | length }}" vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" diff --git a/roles/install_galaxy/defaults/main.yaml b/roles/install_galaxy/defaults/main.yaml new file mode 100644 index 00000000..2f492215 --- /dev/null +++ b/roles/install_galaxy/defaults/main.yaml @@ -0,0 +1,2 @@ +# Packages +pkgs_galaxy: [ ibm.ibm_zhmc, community.general, community.crypto, ansible.posix, community.libvirt ] diff --git a/roles/install_galaxy/tasks/main.yaml b/roles/install_galaxy/tasks/main.yaml new file mode 100644 index 00000000..9203016b --- /dev/null +++ b/roles/install_galaxy/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- name: Print the list of Ansible Galaxy collection packages to be installed and updated. + tags: install_packages + debug: msg={{ pkgs_galaxy }} + +- name: Ensure Ansible Galaxy collections have been installed with latest version. + tags: galaxy + command: ansible-galaxy collection install {{ item }} --upgrade + loop: "{{ pkgs_galaxy }}" diff --git a/roles/install_packages/defaults/main.yaml b/roles/install_packages/defaults/main.yaml new file mode 100644 index 00000000..10df4b63 --- /dev/null +++ b/roles/install_packages/defaults/main.yaml @@ -0,0 +1,4 @@ +# Packages +pkgs_controller: [ openssh, expect, sshuttle ] +pkgs_kvm: [ libguestfs, libvirt-client, libvirt-daemon-config-network, libvirt-daemon-kvm, cockpit-machines, libvirt-devel, virt-top, qemu-kvm, python3-lxml, cockpit, lvm2 ] +pkgs_bastion: [ haproxy, httpd, bind, bind-utils, expect, firewalld, mod_ssl, python3-policycoreutils, rsync ] diff --git a/roles/install_packages/tasks/main.yaml b/roles/install_packages/tasks/main.yaml index f6c9ad0d..5b15fcd3 100644 --- a/roles/install_packages/tasks/main.yaml +++ b/roles/install_packages/tasks/main.yaml @@ -1,8 +1,7 @@ --- - name: Print the list of packages to be installed and updated. tags: install_packages - debug: - var: packages + debug: msg={{ vars[packages] }} - name: Installing required packages for Linux machines. tags: install_packages @@ -11,7 +10,7 @@ name: "{{ item }}" state: latest update_cache: yes - loop: "{{ packages }}" + loop: "{{ vars[packages] }}" when: ansible_os_family != 'Darwin' - name: Installing required packages for Mac machines. @@ -20,5 +19,5 @@ community.general.homebrew: name: "{{ item }}" state: latest - loop: "{{ packages }}" + loop: "{{ vars[packages] }}" when: ansible_os_family == 'Darwin' diff --git a/roles/install_tessia_baselib/defaults/main.yaml b/roles/install_tessia_baselib/defaults/main.yaml new file mode 100644 index 00000000..ef4dbd55 --- /dev/null +++ b/roles/install_tessia_baselib/defaults/main.yaml @@ -0,0 +1,2 @@ +# Packages +pkgs_zvm: [ git, python3-pip, python3-devel, openssl-devel, rust, cargo, libffi-devel, wget, tar, jq, gcc, make, x3270, python39 ] diff --git a/roles/install_tessia_baselib/tasks/main.yaml b/roles/install_tessia_baselib/tasks/main.yaml index adc85004..92191bef 100644 --- a/roles/install_tessia_baselib/tasks/main.yaml +++ b/roles/install_tessia_baselib/tasks/main.yaml @@ -4,7 +4,7 @@ name: - "{{ item }}" state: present - loop: "{{ env.pkgs.zvm }}" + loop: "{{ pkgs_zvm }}" - name: Install setuptools_rust using pip pip: