From e7973d7ff95ef2411c403f7d852b1aa44c3ba7ae Mon Sep 17 00:00:00 2001 From: Klaus Smolin <88041391+smolin-de@users.noreply.github.com> Date: Mon, 10 Apr 2023 05:43:04 +0200 Subject: [PATCH] fix: Adjust boolean code style (#110) Signed-off-by: Klaus Smolin --- playbooks/0_setup.yaml | 10 +++--- playbooks/2_create_kvm_host.yaml | 8 ++--- playbooks/3_setup_kvm_host.yaml | 13 ++++---- playbooks/5_setup_bastion.yaml | 10 +++--- playbooks/6_create_nodes.yaml | 6 ++-- playbooks/pre-existing_site.yaml | 2 +- roles/create_bastion/tasks/main.yaml | 1 - roles/get_ocp/tasks/main.yaml | 31 +++++++++---------- roles/install_packages/tasks/main.yaml | 5 ++- .../wait_for_install_complete/tasks/main.yaml | 5 ++- 10 files changed, 43 insertions(+), 48 deletions(-) diff --git a/playbooks/0_setup.yaml b/playbooks/0_setup.yaml index 610e8bb2..ea718146 100644 --- a/playbooks/0_setup.yaml +++ b/playbooks/0_setup.yaml @@ -3,8 +3,8 @@ - hosts: localhost tags: localhost connection: local - become: False - gather_facts: True + become: false + gather_facts: true roles: - set_inventory @@ -54,8 +54,8 @@ - hosts: localhost connection: local - become: False - gather_facts: True + become: false + gather_facts: true vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" vars: @@ -65,4 +65,4 @@ - install_packages - ssh_key_gen - ssh_agent - - ssh_copy_id #to file server \ No newline at end of file + - ssh_copy_id #to file server diff --git a/playbooks/2_create_kvm_host.yaml b/playbooks/2_create_kvm_host.yaml index 5cef9590..5f7dc704 100644 --- a/playbooks/2_create_kvm_host.yaml +++ b/playbooks/2_create_kvm_host.yaml @@ -20,7 +20,7 @@ tags: update_cfgs, update, kvm_host_2 become: false gather_facts: false - vars_files: + vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" tasks: - name: Include vars for a second KVM host if it is to be created. @@ -38,7 +38,7 @@ tags: update_cfgs, update, kvm_host_3 become: false gather_facts: false - vars_files: + vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" tasks: - name: Include vars for third KVM host if it is to be created. @@ -90,8 +90,8 @@ include_vars: file: "{{ inventory_dir }}/host_vars/{{ env.z.lpar3.hostname }}.yaml" when: env.z.lpar3.create == True - + - name: Boot and install RHEL for a third KVM host. import_role: name: create_kvm_host - when: env.z.lpar3.create == True \ No newline at end of file + when: env.z.lpar3.create == True diff --git a/playbooks/3_setup_kvm_host.yaml b/playbooks/3_setup_kvm_host.yaml index dd66dc0c..d4dfc569 100644 --- a/playbooks/3_setup_kvm_host.yaml +++ b/playbooks/3_setup_kvm_host.yaml @@ -6,7 +6,7 @@ connection: local become: false gather_facts: true - vars_files: + vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" vars: ssh_target: ["{{ env.z.lpar1.ip }}","{{ env.z.lpar1.user }}","{{ env.z.lpar1.pass }}","{{ path_to_key_pair }}"] @@ -25,7 +25,7 @@ connection: local become: false gather_facts: false - vars_files: + vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" vars: ssh_target: ["{{ env.z.lpar2.ip }}","{{ env.z.lpar2.user }}","{{ env.z.lpar2.pass }}","{{ path_to_key_pair }}"] @@ -47,7 +47,7 @@ connection: local become: false gather_facts: false - vars_files: + vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" vars: ssh_target: ["{{ env.z.lpar3.ip }}","{{ env.z.lpar3.user }}","{{ env.z.lpar3.pass }}","{{ path_to_key_pair }}"] @@ -68,7 +68,7 @@ tags: setup, section_2 gather_facts: true become: true - vars: + vars: packages: "{{ env.pkgs.kvm }}" roles: - { role: attach_subscription, when: env.redhat.username is defined and env.redhat.password is defined } @@ -124,7 +124,7 @@ loop: - /etc/libvirt/qemu.conf - "/home/{{ ansible_user }}/.config/libvirt/libvirt.conf" - - /etc/libvirt/libvirt.conf + - /etc/libvirt/libvirt.conf - name: Ensure KVM admin user is part of groups 'kvm', 'libvirt'. tags: groups, group, libvirt @@ -160,7 +160,7 @@ sysctl_set: true state: present reload: true - when: env.network_mode | upper == 'NAT' + when: env.network_mode | upper == 'NAT' - hosts: kvm_host tags: setup, section_3 @@ -168,4 +168,3 @@ roles: - configure_storage - { role: macvtap, when: env.network_mode | upper != 'NAT' } - \ No newline at end of file diff --git a/playbooks/5_setup_bastion.yaml b/playbooks/5_setup_bastion.yaml index f9fd200a..31449c6c 100644 --- a/playbooks/5_setup_bastion.yaml +++ b/playbooks/5_setup_bastion.yaml @@ -59,7 +59,7 @@ - name: 5 setup bastion - configure bastion node with essential services hosts: bastion tags: services, section_2 - become: True + become: true vars: packages: "{{ env.pkgs.bastion }}" vars_files: @@ -80,7 +80,7 @@ - hosts: bastion tags: services, section_2, openvpn - become: True + become: true vars: openvpn_role: "server" roles: @@ -119,8 +119,8 @@ - name: setup OpenVPN on KVM host(s). hosts: kvm_host tags: services, section_3, openvpn - become: True - gather_facts: False + become: true + gather_facts: false vars: openvpn_role: "client" openvpn_client_server: "{{ env.bastion.networking.ip }}" @@ -169,7 +169,7 @@ - hosts: bastion tags: get_ocp, section_3 - become: True + become: true vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" roles: diff --git a/playbooks/6_create_nodes.yaml b/playbooks/6_create_nodes.yaml index 8571dc71..013b4f5d 100644 --- a/playbooks/6_create_nodes.yaml +++ b/playbooks/6_create_nodes.yaml @@ -27,7 +27,7 @@ - name: 6 create nodes - wait for bootstrap to connect control plane (for non-root user) hosts: bastion - become: True + become: true environment: KUBECONFIG: "/home/{{ env.bastion.access.user }}/.kube/config" gather_facts: true @@ -38,7 +38,7 @@ - name: 6 create nodes - wait for bootstrap to connect to control plane (for root user) hosts: bastion - become: True + become: true environment: KUBECONFIG: "/{{ env.bastion.access.user }}/.kube/config" gather_facts: true @@ -50,7 +50,7 @@ - name: 6 create nodes - once bootstrapping is complete, tear down bootstrap. hosts: kvm_host[-1] tags: create_nodes, teardown_bootstrap - gather_facts: False + gather_facts: false vars_files: - "{{ inventory_dir }}/group_vars/all.yaml" tasks: diff --git a/playbooks/pre-existing_site.yaml b/playbooks/pre-existing_site.yaml index c8819f0d..a2b22daf 100644 --- a/playbooks/pre-existing_site.yaml +++ b/playbooks/pre-existing_site.yaml @@ -6,4 +6,4 @@ - import_playbook: 4_create_bastion.yaml - import_playbook: 5_setup_bastion.yaml - import_playbook: 6_create_nodes.yaml -- import_playbook: 7_ocp_verification.yaml \ No newline at end of file +- import_playbook: 7_ocp_verification.yaml diff --git a/roles/create_bastion/tasks/main.yaml b/roles/create_bastion/tasks/main.yaml index 9209620c..58fbbcf5 100644 --- a/roles/create_bastion/tasks/main.yaml +++ b/roles/create_bastion/tasks/main.yaml @@ -1,5 +1,4 @@ --- - - name: Create a directory on the KVM host server for bastion configuration files become: false tags: create_bastion diff --git a/roles/get_ocp/tasks/main.yaml b/roles/get_ocp/tasks/main.yaml index 2d625ed9..416f7572 100644 --- a/roles/get_ocp/tasks/main.yaml +++ b/roles/get_ocp/tasks/main.yaml @@ -1,5 +1,4 @@ --- - - name: Delete ignition folder for idempotency tags: get_ocp file: @@ -12,7 +11,7 @@ file: path: /var/www/html/bin state: directory - mode: '0755' + mode: "0755" owner: "root" group: "root" @@ -34,7 +33,7 @@ get_url: url: "https://mirror.openshift.com/pub/openshift-v{{ env.openshift.version | string | split('.') | first }}/{{ env.install_config.control.architecture }}/dependencies/rhcos/{{ ( env.openshift.version | string | split('.') )[:-1] | join('.') }}/{{ env.openshift.version }}/rhcos-live-rootfs.{{ env.install_config.control.architecture }}.img" dest: "/var/www/html/bin/rhcos-live-rootfs-{{ env.openshift.version }}-{{ env.install_config.control.architecture }}.img" - mode: '0644' + mode: "0644" - name: Unzip OCP client and installer tags: get_ocp @@ -54,7 +53,7 @@ dest: /usr/sbin/{{ item }} owner: root group: root - mode: '755' + mode: "755" remote_src: yes loop: - kubectl @@ -97,8 +96,8 @@ become: true replace: path: /root/ocpinst/manifests/cluster-scheduler-02-config.yml - regexp: ': true' - replace: ': false' + regexp: ": true" + replace: ": false" - name: Set permissions for ocpinst directory contents to root tags: get_ocp @@ -134,24 +133,24 @@ group: root mode: "{{ item.mode }}" loop: - - { state: file, path: bootstrap.ign, mode: '755' } - - { state: file, path: master.ign, mode: '755' } - - { state: file, path: worker.ign, mode: '755' } - - { state: directory, path: auth, mode: '755' } - - { state: file, path: metadata.json, mode: '755' } - - { state: file, path: auth/kubeconfig, mode: '644' } - - { state: file, path: auth/kubeadmin-password, mode: '644' } + - { state: file, path: bootstrap.ign, mode: "755" } + - { state: file, path: master.ign, mode: "755" } + - { state: file, path: worker.ign, mode: "755" } + - { state: directory, path: auth, mode: "755" } + - { state: file, path: metadata.json, mode: "755" } + - { state: file, path: auth/kubeconfig, mode: "644" } + - { state: file, path: auth/kubeadmin-password, mode: "644" } - name: Create directory in admin user's home for default kubeconfig. tags: get_ocp, config - become: False + become: false file: state: directory path: ~/.kube - name: Create directory in root's home for default kubeconfig. tags: get_ocp, config - become: True + become: true file: state: directory path: ~/.kube @@ -199,7 +198,7 @@ src: /root/ocpinst/{{ item }}.ign dest: /var/www/html/ignition remote_src: yes - mode: '775' + mode: "775" group: root owner: root loop: diff --git a/roles/install_packages/tasks/main.yaml b/roles/install_packages/tasks/main.yaml index fe852071..f6c9ad0d 100644 --- a/roles/install_packages/tasks/main.yaml +++ b/roles/install_packages/tasks/main.yaml @@ -1,5 +1,4 @@ --- - - name: Print the list of packages to be installed and updated. tags: install_packages debug: @@ -7,7 +6,7 @@ - name: Installing required packages for Linux machines. tags: install_packages - become: True + become: true ansible.builtin.package: name: "{{ item }}" state: latest @@ -17,7 +16,7 @@ - name: Installing required packages for Mac machines. tags: install_packages - become: False + become: false community.general.homebrew: name: "{{ item }}" state: latest diff --git a/roles/wait_for_install_complete/tasks/main.yaml b/roles/wait_for_install_complete/tasks/main.yaml index b45a57f6..fe59ca68 100644 --- a/roles/wait_for_install_complete/tasks/main.yaml +++ b/roles/wait_for_install_complete/tasks/main.yaml @@ -1,5 +1,4 @@ --- - - name: Almost there! Add host info to /etc/hosts so you can login to the cluster via web browser. Ansible Controller sudo password required tags: wait_for_install_complete become: true @@ -27,7 +26,7 @@ - name: "Additional step, if using NAT" tags: wait_for_install_complete - debug: + debug: msg: "NAT USERS ONLY: Create SSH tunnel to cluster, i.e run command in terminal window from controller: 'sshuttle -r {{ env.bastion.access.user }}@{{ env.bastion.networking.ip }} 192.168.122.0/15 --dns'" when: ( env.network_mode | upper == "NAT" ) changed_when: false @@ -35,7 +34,7 @@ - name: Congratulations! OpenShift installation complete. Use the information below for first-time login via web browser. tags: wait_for_install_complete command: "echo {{ item }}" - loop: + loop: - " URL: {{ ocp_url }} " - " Username: kubeadmin " - " Password: {{ ocp_passwd.stdout }} "