diff --git a/roles/reproducer/README.md b/roles/reproducer/README.md index 5dbf8fba86..ca2857e938 100644 --- a/roles/reproducer/README.md +++ b/roles/reproducer/README.md @@ -6,8 +6,10 @@ None ## Parameters -* `cifmw_reproducer_user`: (String) User used for reproducer role. Defaults to `zuul` * `cifmw_reproducer_basedir`: (String) Base directory. Defaults to `cifmw_basedir`, which defaults to `~/ci-framework-data`. +* `cifmw_reproducer_controller_user`: (String) User on controller-0. Defaults to `ansible_ssh_user` from controller-0's `hostvars` if available, otherwise defaults to `zuul`. +* `cifmw_reproducer_controller_user_dir`: (String) Controller-0 user's home dir. Defaults to `/home/{{ cifmw_reproducer_controller_user }}` +* `cifmw_reproducer_controller_basedir`: (String) Path to the `ci-framework-data` dir on controller-0. Defaults to `"{{ cifmw_reproducer_controller_user_dir }}/ci-framework-data"` * `cifmw_reproducer_compute_repos`: (List[mapping]) List of yum repository that must be deployed on the compute nodes during their creation. Defaults to `[]`. * `cifmw_reproducer_compute_set_repositories`: (Bool) Deploy repositories (rhos-release) on Compute nodes. Defaults to `true`. * `cifmw_reproducer_play_extravars`: (List[string]) List of extra-vars you want to pass down to the EDPM deployment playbooks. Defaults to `[]`. diff --git a/roles/reproducer/defaults/main.yml b/roles/reproducer/defaults/main.yml index a005e9d93f..e1ec06b9fb 100644 --- a/roles/reproducer/defaults/main.yml +++ b/roles/reproducer/defaults/main.yml @@ -17,7 +17,9 @@ # All variables intended for modification should be placed in this file. # All variables within this role should have a prefix of "cifmw_reproducer" -cifmw_reproducer_user: "{{ ansible_user | default('zuul') }}" +cifmw_reproducer_controller_user: "{{ hostvars['controller-0']['ansible_ssh_user'] }}" +cifmw_reproducer_controller_user_dir: "/home/{{ cifmw_reproducer_controller_user }}" +cifmw_reproducer_controller_basedir: "{{ cifmw_reproducer_controller_user_dir }}/ci-framework-data" cifmw_reproducer_basedir: "{{ cifmw_basedir | default( ansible_user_dir ~ '/ci-framework-data') }}" cifmw_reproducer_src_dir: "{{ cifmw_ci_src_dir | default( ansible_user_dir ~ '/src') }}" cifmw_reproducer_kubecfg: "{{ cifmw_libvirt_manager_configuration.vms.crc.image_local_dir }}/kubeconfig" @@ -40,13 +42,6 @@ cifmw_reproducer_supported_hypervisor_os: minimum_version: 9 RedHat: minimum_version: 9.3 -cifmw_reproducer_controller_basedir: >- - {{ - ( - '/home/zuul', - 'ci-framework-data', - ) | path_join - }} # Allow to disable validations - user toggle this at their # own risks! diff --git a/roles/reproducer/tasks/ci_job.yml b/roles/reproducer/tasks/ci_job.yml index 397ef10b7b..1495cb589e 100644 --- a/roles/reproducer/tasks/ci_job.yml +++ b/roles/reproducer/tasks/ci_job.yml @@ -23,18 +23,18 @@ block: - name: Ensure directory exists ansible.builtin.file: - path: "/home/zuul/{{ job_id }}-params" + path: "{{ cifmw_reproducer_controller_user_dir }}/{{ job_id }}-params" mode: "0755" state: directory - owner: "{{ cifmw_reproducer_user }}" - group: "{{ cifmw_reproducer_user }}" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" - name: Copy environment files to controller node tags: - bootstrap ansible.builtin.copy: src: "{{ _reproducer_basedir }}/parameters/" - dest: "/home/zuul/{{ job_id }}-params" + dest: "{{ cifmw_reproducer_controller_user_dir }}/{{ job_id }}-params" mode: "0644" - name: Inject reproducer dedicated parameter file @@ -42,7 +42,7 @@ - bootstrap ansible.builtin.template: src: "reproducer_params.yml.j2" - dest: "/home/zuul/{{ job_id }}-params/reproducer_params.yml" + dest: "{{ cifmw_reproducer_controller_user_dir }}/{{ job_id }}-params/reproducer_params.yml" mode: "0644" - name: Generate CI job playbook @@ -70,7 +70,7 @@ tags: - bootstrap ansible.builtin.copy: - dest: /home/zuul/zuul-network-data.yml + dest: "{{ cifmw_reproducer_controller_user_dir }}/zuul-network-data.yml" content: "{{ {'job_network': ci_job_networking} | to_nice_yaml}}" mode: "0644" @@ -96,7 +96,7 @@ items2dict }} ansible.builtin.copy: - dest: "/home/zuul/ci-framework-data/artifacts/parameters/zuul-params.yml" + dest: "{{ cifmw_reproducer_controller_basedir }}/artifacts/parameters/zuul-params.yml" content: "{{ {'zuul': zuul_params_filtered} | to_nice_yaml }}" mode: "0644" @@ -105,14 +105,14 @@ - always ansible.builtin.include_tasks: rotate_log.yml loop: - - "/home/zuul/ansible.log" - - "/home/zuul/ansible-pre-ci.log" - - "/home/zuul/ansible-{{ job_id }}.log" - - "/home/zuul/ansible-content-provider-bootstrap.log" + - "{{ cifmw_reproducer_controller_user_dir }}/ansible.log" + - "{{ cifmw_reproducer_controller_user_dir }}/ansible-pre-ci.log" + - "{{ cifmw_reproducer_controller_user_dir }}/ansible-{{ job_id }}.log" + - "{{ cifmw_reproducer_controller_user_dir }}/ansible-content-provider-bootstrap.log" - name: Generate and run scripts vars: - _home: "/home/zuul" + _home: "{{ cifmw_reproducer_controller_user_dir }}" run_directory: "{{ _cifmw_reproducer_framework_location }}" block: - name: Generate pre-ci-play script diff --git a/roles/reproducer/tasks/configure_architecture.yml b/roles/reproducer/tasks/configure_architecture.yml index 3eb0e70d03..abb06b50f5 100644 --- a/roles/reproducer/tasks/configure_architecture.yml +++ b/roles/reproducer/tasks/configure_architecture.yml @@ -6,18 +6,18 @@ vars: run_directory: "{{ _cifmw_reproducer_framework_location }}" exports: - ANSIBLE_LOG_PATH: "{{ ansible_user_dir }}/ci-framework-data/logs/ansible-deploy-architecture.log" + ANSIBLE_LOG_PATH: "{{ cifmw_reproducer_controller_basedir }}/logs/ansible-deploy-architecture.log" default_extravars: - "@~/ci-framework-data/parameters/reproducer-variables.yml" - "@~/ci-framework-data/parameters/openshift-environment.yml" extravars: "{{ cifmw_reproducer_play_extravars }}" playbook: "deploy-edpm.yml" ansible.builtin.template: - dest: "/home/zuul/deploy-architecture.sh" + dest: "{{ cifmw_reproducer_controller_user_dir }}/deploy-architecture.sh" src: "script.sh.j2" mode: "0755" - owner: "zuul" - group: "zuul" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" - name: Rotate some logs tags: diff --git a/roles/reproducer/tasks/configure_cleanup.yaml b/roles/reproducer/tasks/configure_cleanup.yaml index b14294c834..6c2463e5b1 100644 --- a/roles/reproducer/tasks/configure_cleanup.yaml +++ b/roles/reproducer/tasks/configure_cleanup.yaml @@ -42,11 +42,11 @@ extravars: "{{ cifmw_reproducer_play_extravars }}" playbook: "clean_openstack_deployment.yaml" ansible.builtin.template: - dest: "/home/zuul/cleanup-architecture.sh" + dest: "{{ cifmw_reproducer_controller_user_dir }}/cleanup-architecture.sh" src: "script.sh.j2" mode: "0755" - owner: "zuul" - group: "zuul" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" - name: Rotate some logs tags: diff --git a/roles/reproducer/tasks/configure_controller.yml b/roles/reproducer/tasks/configure_controller.yml index d1d1404108..54d6f2aa43 100644 --- a/roles/reproducer/tasks/configure_controller.yml +++ b/roles/reproducer/tasks/configure_controller.yml @@ -1,14 +1,4 @@ --- -- name: Set facts related to the reproducer - ansible.builtin.set_fact: - _ctl_reproducer_basedir: >- - {{ - ( - '/home/zuul', - 'ci-framework-data', - ) | path_join - }} - # The dynamic inventory sets the ansible_ssh_user to zuul once we get the proper # ssh configuration accesses set. - name: Configure controller-0 @@ -25,14 +15,10 @@ cifmw_sushy_emulator_install_type: podman cifmw_sushy_emulator_hypervisor_address: >- {{ inventory_hostname }}.utility - cifmw_sushy_emulator_basedir: "{{ _ctl_reproducer_basedir }}" + cifmw_sushy_emulator_basedir: "{{ cifmw_reproducer_controller_basedir }}" cifmw_sushy_emulator_connection_name: "sushy.utility" - cifmw_sushy_emulator_sshkey_path: >- - {{ - [_ctl_reproducer_basedir, '../.ssh/sushy_emulator-key'] | - path_join - }} - cifmw_podman_user_linger: "zuul" + cifmw_sushy_emulator_sshkey_path: "{{ cifmw_reproducer_controller_user_dir }}/.ssh/sushy_emulator-key" + cifmw_podman_user_linger: "{{ cifmw_reproducer_controller_user }}" cifmw_sushy_emulator_libvirt_user: >- {{ hostvars[cifmw_sushy_emulator_hypervisor_target].ansible_user_id | @@ -41,7 +27,7 @@ block: - name: Ensure directories exist ansible.builtin.file: - path: "{{ _ctl_reproducer_basedir }}/{{ item }}" + path: "{{ cifmw_reproducer_controller_basedir }}/{{ item }}" state: directory mode: "0755" loop: @@ -118,14 +104,14 @@ - bootstrap ansible.builtin.shell: cmd: >- - cat /home/zuul/reproducer-inventory/* > - {{ _ctl_reproducer_basedir }}/artifacts/zuul_inventory.yml + cat {{ cifmw_reproducer_controller_user_dir }}/reproducer-inventory/* > + {{ cifmw_reproducer_controller_basedir }}/artifacts/zuul_inventory.yml # You want to use the "name" parameter of the ansible.builtin.include_vars # call, such as: # - name: Load mac mapping # ansible.builtin.include_vars: - # file: "{{ _ctl_reproducer_basedir }}/parameters/interfaces-info.yml" + # file: "{{ cifmw_reproducer_controller_basedir }}/parameters/interfaces-info.yml" # name: my_fancy_name # Then you'll be able to access the mapping content via `my_fancy_name`. - name: Push the MAC mapping data @@ -135,7 +121,7 @@ - cifmw_libvirt_manager_mac_map is defined ansible.builtin.copy: mode: "0644" - dest: "{{ _ctl_reproducer_basedir }}/parameters/interfaces-info.yml" + dest: "{{ cifmw_reproducer_controller_basedir }}/parameters/interfaces-info.yml" content: "{{ cifmw_libvirt_manager_mac_map | to_nice_yaml }}" - name: Inject other Hypervisor SSH keys @@ -149,7 +135,7 @@ default(hostvars[host]['inventory_hostname']) }} ansible.builtin.copy: - dest: "/home/zuul/.ssh/ssh_{{ _ssh_host }}" + dest: "{{ cifmw_reproducer_controller_user_dir }}/.ssh/ssh_{{ _ssh_host }}" content: "{{ _ssh_key }}" mode: "0600" loop: "{{ hostvars.keys() }}" @@ -175,7 +161,7 @@ ansible.builtin.blockinfile: create: true mode: "0600" - path: "/home/zuul/.ssh/config" + path: "{{ cifmw_reproducer_controller_user_dir }}/.ssh/config" marker: "## {mark} {{ _ssh_host }}" block: |- Host {{ _ssh_host }} {{ hostvars[host]['inventory_hostname'] }} @@ -210,7 +196,7 @@ ansible.builtin.blockinfile: create: true mode: "0600" - path: "/home/zuul/.ssh/config" + path: "{{ cifmw_reproducer_controller_user_dir }}/.ssh/config" marker: "## {mark} {{ host }}" block: |- Host {{ host }} {{ _hostname }} {{ _hostname }}.utility {{ hostvars[host].ansible_host }} @@ -232,10 +218,10 @@ - name: Create kube directory ansible.builtin.file: - path: "/home/zuul/.kube" + path: "{{ cifmw_reproducer_controller_user_dir }}/.kube" state: directory - owner: "{{ cifmw_reproducer_user }}" - group: "{{ cifmw_reproducer_user }}" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" mode: "0750" - name: Inject kubeconfig content @@ -243,15 +229,15 @@ - _devscripts_kubeconfig.content is defined or _crc_kubeconfig.content is defined ansible.builtin.copy: - dest: "/home/zuul/.kube/config" + dest: "{{ cifmw_reproducer_controller_user_dir }}/.kube/config" content: >- {{ (_use_ocp | bool) | ternary(_devscripts_kubeconfig.content, _crc_kubeconfig.content) | b64decode }} - owner: "{{ cifmw_reproducer_user }}" - group: "{{ cifmw_reproducer_user }}" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" mode: "0640" - name: Inject kubeadmin-password if exists @@ -259,25 +245,25 @@ - _devscripts_kubeadm.content is defined or _crc_kubeadm.content is defined ansible.builtin.copy: - dest: "/home/zuul/.kube/kubeadmin-password" + dest: "{{ cifmw_reproducer_controller_user_dir }}/.kube/kubeadmin-password" content: >- {{ (_devscripts_kubeadm.content is defined) | ternary(_devscripts_kubeadm.content, _crc_kubeadm.content) | b64decode }} - owner: "{{ cifmw_reproducer_user }}" - group: "{{ cifmw_reproducer_user }}" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" mode: "0600" - name: Inject devscripts private key if set when: - _devscript_privkey.content is defined ansible.builtin.copy: - dest: "{{ ansible_user_dir }}/.ssh/devscripts_key" + dest: "{{ cifmw_reproducer_controller_user_dir }}/.ssh/devscripts_key" content: "{{ _devscript_privkey.content | b64decode }}" - owner: "{{ cifmw_reproducer_user }}" - group: "{{ cifmw_reproducer_user }}" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" mode: "0400" - name: Ensure /etc/ci/env is created @@ -289,8 +275,8 @@ - name: Manage secrets on controller-0 vars: - cifmw_manage_secrets_basedir: "/home/zuul/ci-framework-data" - cifmw_manage_secrets_owner: "{{ cifmw_reproducer_user }}" + cifmw_manage_secrets_basedir: "{{ cifmw_reproducer_controller_basedir }}" + cifmw_manage_secrets_owner: "{{ cifmw_reproducer_controller_user }}" block: - name: Initialize secret manager ansible.builtin.import_role: @@ -362,7 +348,7 @@ delegate_to: localhost ansible.posix.synchronize: src: "{{ cifmw_reproducer_src_dir }}/" - dest: "zuul@{{ item }}:{{ cifmw_reproducer_src_dir }}" + dest: "{{ cifmw_reproducer_controller_user }}@{{ item }}:{{ cifmw_reproducer_controller_user_dir }}/src" archive: true recursive: true loop: "{{ groups['controllers'] }}" @@ -371,11 +357,10 @@ - cifmw_reproducer_src_dir_stat.stat.exists - cifmw_reproducer_src_dir_stat.stat.isdir - - name: Check if local common-requirements.txt exists - delegate_to: localhost + - name: Check if common-requirements.txt exists on controller-0 ansible.builtin.stat: - path: "{{ cifmw_project_dir_absolute }}/common-requirements.txt" - register: _local_common_requirements_check + path: "{{ cifmw_reproducer_controller_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework/common-requirements.txt" + register: _controller_common_requirements_check run_once: true ignore_errors: true @@ -384,10 +369,10 @@ async: 600 # 10 minutes should be more than enough poll: 0 ansible.builtin.pip: - requirements: "{{ have_local | ternary(local, remote) }}" + requirements: "{{ have_controller_reqs | ternary(controller_reqs, remote) }}" vars: - have_local: "{{ _local_common_requirements_check.stat is defined and _local_common_requirements_check.stat.exists }}" - local: "{{ cifmw_project_dir_absolute }}/common-requirements.txt" + have_controller_reqs: "{{ _controller_common_requirements_check.stat is defined and _controller_common_requirements_check.stat.exists }}" + controller_reqs: "{{ cifmw_reproducer_controller_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework/common-requirements.txt" remote: https://raw.githubusercontent.com/openstack-k8s-operators/ci-framework/main/common-requirements.txt - name: Inject most of the cifmw_ parameters passed to the reproducer run @@ -417,19 +402,19 @@ }} ansible.builtin.copy: mode: "0644" - dest: "/home/zuul/ci-framework-data/parameters/reproducer-variables.yml" + dest: "{{ cifmw_reproducer_controller_basedir }}/parameters/reproducer-variables.yml" content: "{{ _filtered_vars | to_nice_yaml }}" - name: Create reproducer-variables.yml symlink to old location ansible.builtin.file: - dest: "/home/zuul/reproducer-variables.yml" - src: "/home/zuul/ci-framework-data/parameters/reproducer-variables.yml" + dest: "{{ cifmw_reproducer_controller_user_dir }}/reproducer-variables.yml" + src: "{{ cifmw_reproducer_controller_basedir }}/parameters/reproducer-variables.yml" state: link - name: Inject local environment parameters ansible.builtin.copy: mode: "0644" - dest: "/home/zuul/ci-framework-data/parameters/openshift-environment.yml" + dest: "{{ cifmw_reproducer_controller_basedir }}/parameters/openshift-environment.yml" content: |- {% raw %} --- @@ -450,14 +435,14 @@ - name: Create openshift-environment.yml symlink to old location ansible.builtin.file: - dest: "/home/zuul/openshift-environment.yml" - src: "/home/zuul/ci-framework-data/parameters/openshift-environment.yml" + dest: "{{ cifmw_reproducer_controller_user_dir }}/openshift-environment.yml" + src: "{{ cifmw_reproducer_controller_basedir }}/parameters/openshift-environment.yml" state: link - name: Get interfaces-info content register: _nic_info ansible.builtin.slurp: - src: "{{ _ctl_reproducer_basedir }}/parameters/interfaces-info.yml" + src: "{{ cifmw_reproducer_controller_basedir }}/parameters/interfaces-info.yml" # We detected OCP cluster may have some downtime even after it's supposed # to be started. @@ -484,7 +469,7 @@ {{ _nic_info.content | b64decode | from_yaml }} cifmw_networking_mapper_network_name: >- {{ _cifmw_libvirt_manager_layout.vms.controller.nets.1 }} - cifmw_networking_mapper_basedir: "/home/zuul/ci-framework-data" + cifmw_networking_mapper_basedir: "{{ cifmw_reproducer_controller_basedir }}" ansible.builtin.import_role: name: networking_mapper @@ -494,11 +479,11 @@ block: - name: Inject CRC ssh key ansible.builtin.copy: - dest: "/home/zuul/.ssh/crc_key" + dest: "{{ cifmw_reproducer_controller_user_dir }}/.ssh/crc_key" content: "{{ crc_priv_key['content'] | b64decode }}" mode: "0400" - owner: "{{ cifmw_reproducer_user }}" - group: "{{ cifmw_reproducer_user }}" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" - name: Ensure we have all dependencies installed ansible.builtin.async_status: diff --git a/roles/reproducer/tasks/configure_post_deployment.yml b/roles/reproducer/tasks/configure_post_deployment.yml index a8a6a27c3c..79bd23453e 100644 --- a/roles/reproducer/tasks/configure_post_deployment.yml +++ b/roles/reproducer/tasks/configure_post_deployment.yml @@ -6,18 +6,18 @@ vars: run_directory: "{{ _cifmw_reproducer_framework_location }}" exports: - ANSIBLE_LOG_PATH: "{{ ansible_user_dir }}/ansible-post-deployment.log" + ANSIBLE_LOG_PATH: "{{ cifmw_reproducer_controller_user_dir }}/ansible-post-deployment.log" default_extravars: - - "@{{ ansible_user_dir }}/ci-framework-data/parameters/reproducer-variables.yml" - - "@{{ ansible_user_dir }}/ci-framework-data/parameters/openshift-environment.yml" + - "@{{ cifmw_reproducer_controller_basedir }}/parameters/reproducer-variables.yml" + - "@{{ cifmw_reproducer_controller_basedir }}/parameters/openshift-environment.yml" extravars: "{{ cifmw_reproducer_play_extravars }}" playbook: "post-deployment.yml" ansible.builtin.template: - dest: "/home/zuul/post_deployment.sh" + dest: "{{ cifmw_reproducer_controller_user_dir }}/post_deployment.sh" src: "script.sh.j2" mode: "0755" - owner: "zuul" - group: "zuul" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" - name: Rotate some logs tags: diff --git a/roles/reproducer/tasks/libvirt_layout.yml b/roles/reproducer/tasks/libvirt_layout.yml index 56da59c775..be682d42d2 100644 --- a/roles/reproducer/tasks/libvirt_layout.yml +++ b/roles/reproducer/tasks/libvirt_layout.yml @@ -46,7 +46,7 @@ ansible.builtin.command: # noqa: command-instead-of-module cmd: >- rsync -r {{ cifmw_reproducer_basedir }}/reproducer-inventory/ - zuul@controller-0:reproducer-inventory + {{ cifmw_reproducer_controller_user }}@controller-0:reproducer-inventory - name: Run post tasks in OCP cluster case when: diff --git a/roles/reproducer/tasks/main.yml b/roles/reproducer/tasks/main.yml index 4f1b81479b..deebf619d0 100644 --- a/roles/reproducer/tasks/main.yml +++ b/roles/reproducer/tasks/main.yml @@ -32,34 +32,6 @@ tags: - bootstrap_layout -- name: Discover and expose CI Framework path on remote node - tags: - - always - vars: - default_path: >- - {{ - cifmw_reproducer_default_repositories | - selectattr('src', 'match', '^.*/ci[_\-]framework$') | - map(attribute='dest') | first - }} - custom_path: >- - {{ - cifmw_reproducer_repositories | - selectattr('src', 'match', '^.*/ci-framework$') | - map(attribute='dest') - }} - _path: >- - {{ - (custom_path | length > 0) | - ternary(custom_path | first, default_path) - }} - ansible.builtin.set_fact: - _cifmw_reproducer_framework_location: >- - {{ - (_path is match('.*/ci-framework/?$')) | - ternary(_path, [_path, 'ci-framework'] | path_join) - }} - - name: Build final libvirt layout tags: - bootstrap_env @@ -252,6 +224,34 @@ }} failed_when: false +- name: Discover and expose CI Framework path on remote node + tags: + - always + vars: + default_path: >- + {{ + cifmw_reproducer_default_repositories | + selectattr('src', 'match', '^.*/ci[_\-]framework$') | + map(attribute='dest') | first + }} + custom_path: >- + {{ + cifmw_reproducer_repositories | + selectattr('src', 'match', '^.*/ci-framework$') | + map(attribute='dest') + }} + _path: >- + {{ + (custom_path | length > 0) | + ternary(custom_path | first, default_path) + }} + ansible.builtin.set_fact: + _cifmw_reproducer_framework_location: >- + {{ + (_path is match('.*/ci-framework/?$')) | + ternary(_path, [_path, 'ci-framework'] | path_join) + }} + - name: Run only on hypervisor with controller-0 when: - ( @@ -281,13 +281,15 @@ - always ansible.builtin.include_tasks: rotate_log.yml loop: - - "/home/zuul/ansible-bootstrap.log" + - "{{ cifmw_reproducer_controller_user_dir }}/ansible-bootstrap.log" - name: Bootstrap environment on controller-0 vars: # NOTE: need to overwrite parent vars: # ./roles/reproducer/molecule/crc_layout/converge.yml - cifmw_basedir: "{{ ansible_user_dir ~ '/ci-framework-data' }}" + cifmw_basedir: "{{ cifmw_reproducer_controller_basedir }}" + ansible_user_dir: "{{ cifmw_reproducer_controller_user_dir }}" + ansible_user_id: "{{ cifmw_reproducer_controller_user }}" no_log: "{{ cifmw_nolog | default(true) | bool }}" ansible.builtin.import_role: name: cifmw_setup @@ -300,7 +302,8 @@ _devsetup_path: >- {{ ( - cifmw_installyamls_repos, + cifmw_reproducer_controller_user_dir, + 'src/github.com/openstack-k8s-operators/install_yamls', 'devsetup' ) | ansible.builtin.path_join }} @@ -310,13 +313,13 @@ cmd: >- ansible-playbook -i ~/ci-framework-data/artifacts/zuul_inventory.yml download_tools.yaml --tags kustomize,kubectl - creates: "/home/zuul/bin/kubectl" + creates: "{{ cifmw_reproducer_controller_user_dir }}/bin/kubectl" - name: Configure CRC network if needed when: - _use_crc | bool vars: - cifmw_openshift_kubeconfig: "/home/zuul/.kube/config" + cifmw_openshift_kubeconfig: "{{ cifmw_reproducer_controller_user_dir }}/.kube/config" ansible.builtin.include_role: name: openshift_setup tasks_from: patch_network_operator.yml @@ -396,8 +399,8 @@ extravars: "{{ cifmw_reproducer_play_extravars }}" playbook: "deploy-edpm.yml" ansible.builtin.template: - dest: "/home/zuul/deploy-edpm.sh" + dest: "{{ cifmw_reproducer_controller_user_dir }}/deploy-edpm.sh" src: "script.sh.j2" mode: "0755" - owner: "zuul" - group: "zuul" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" diff --git a/roles/reproducer/tasks/push_code.yml b/roles/reproducer/tasks/push_code.yml index 985b9e655e..c32ef15f6a 100644 --- a/roles/reproducer/tasks/push_code.yml +++ b/roles/reproducer/tasks/push_code.yml @@ -78,7 +78,6 @@ - name: Push random code into the proper location vars: - repo_base_dir: '/home/zuul/src' _cifmw_reproducer_all_repositories: "{{ cifmw_reproducer_repositories | default([]) }}" block: - name: Expand cifmw_reproducer_repositories to pull code from ansible controller to controller-0 @@ -95,7 +94,7 @@ _user_sources: "{{ cifmw_reproducer_repositories | default([]) | map(attribute='src') }}" _repo_entry: src: "{{ ansible_user_dir }}/{{ repo.value.src_dir | regex_replace('/$', '') }}/" - dest: "/home/zuul/{{ repo.value.src_dir }}" + dest: "{{ cifmw_reproducer_controller_user_dir }}/{{ repo.value.src_dir }}" ansible.builtin.set_fact: _cifmw_reproducer_all_repositories: "{{ _cifmw_reproducer_all_repositories + [_repo_entry] }}" loop: "{{ _zuul['projects'] | dict2items }}" @@ -126,7 +125,7 @@ - item.src is abs or item.src is not match('.*:.*') ansible.posix.synchronize: src: "{{ item.src }}" - dest: "zuul@controller-0:{{ item.dest }}" + dest: "{{ cifmw_reproducer_controller_user }}@controller-0:{{ item.dest }}" archive: true recursive: true delete: true diff --git a/roles/reproducer/tasks/reuse_main.yaml b/roles/reproducer/tasks/reuse_main.yaml index a0c4d92a51..db5630a924 100644 --- a/roles/reproducer/tasks/reuse_main.yaml +++ b/roles/reproducer/tasks/reuse_main.yaml @@ -114,7 +114,7 @@ - always ansible.builtin.include_tasks: rotate_log.yml loop: - - "/home/zuul/ansible-bootstrap.log" + - "{{ cifmw_reproducer_controller_user_dir }}/ansible-bootstrap.log" - name: Bootstrap environment on controller-0 environment: @@ -127,7 +127,7 @@ -e @~/ci-framework-data/parameters/reproducer-variables.yml -e @scenarios/reproducers/networking-definition.yml playbooks/01-bootstrap.yml - creates: "/home/zuul/ansible-bootstrap.log" + creates: "{{ cifmw_reproducer_controller_user_dir }}/ansible-bootstrap.log" - name: Install dev tools from install_yamls on controller-0 environment: @@ -136,7 +136,8 @@ _devsetup_path: >- {{ ( - cifmw_installyamls_repos, + cifmw_reproducer_controller_user_dir, + 'src/github.com/openstack-k8s-operators/install_yamls', 'devsetup' ) | ansible.builtin.path_join }} @@ -146,7 +147,7 @@ cmd: >- ansible-playbook -i ~/ci-framework-data/artifacts/zuul_inventory.yml download_tools.yaml --tags kustomize,kubectl - creates: "/home/zuul/bin/kubectl" + creates: "{{ cifmw_reproducer_controller_user_dir }}/bin/kubectl" # Run from the hypervisor - name: Ensure OCP cluster is stable @@ -201,19 +202,9 @@ ansible.builtin.include_tasks: file: configure_post_deployment.yml - - name: Set facts related to the reproducer - ansible.builtin.set_fact: - _ctl_reproducer_basedir: >- - {{ - ( - '/home/zuul', - 'ci-framework-data', - ) | path_join - }} - - name: Ensure directories exist ansible.builtin.file: - path: "{{ _ctl_reproducer_basedir }}/{{ item }}" + path: "{{ cifmw_reproducer_controller_basedir }}/{{ item }}" state: directory mode: "0755" loop: @@ -247,18 +238,18 @@ }} ansible.builtin.copy: mode: "0644" - dest: "/home/zuul/ci-framework-data/parameters/reproducer-variables.yml" + dest: "{{ cifmw_reproducer_controller_basedir }}/parameters/reproducer-variables.yml" content: "{{ _filtered_vars | to_nice_yaml }}" - name: Create reproducer-variables.yml symlink to old location ansible.builtin.file: - dest: "/home/zuul/reproducer-variables.yml" - src: "/home/zuul/ci-framework-data/parameters/reproducer-variables.yml" + dest: "{{ cifmw_reproducer_controller_user_dir }}/reproducer-variables.yml" + src: "{{ cifmw_reproducer_controller_basedir }}/parameters/reproducer-variables.yml" state: link - name: Slurp kubeadmin password ansible.builtin.slurp: - src: /home/zuul/.kube/kubeadmin-password + src: "{{ cifmw_reproducer_controller_user_dir }}/.kube/kubeadmin-password" register: _kubeadmin_password - name: Prepare ci-like EDPM deploy @@ -276,8 +267,8 @@ extravars: "{{ cifmw_reproducer_play_extravars }}" playbook: "deploy-edpm.yml" ansible.builtin.template: - dest: "/home/zuul/deploy-edpm.sh" + dest: "{{ cifmw_reproducer_controller_user_dir }}/deploy-edpm.sh" src: "script.sh.j2" mode: "0755" - owner: "zuul" - group: "zuul" + owner: "{{ cifmw_reproducer_controller_user }}" + group: "{{ cifmw_reproducer_controller_user }}" diff --git a/roles/reproducer/templates/reproducer_params.yml.j2 b/roles/reproducer/templates/reproducer_params.yml.j2 index 8862925691..d5f9882937 100644 --- a/roles/reproducer/templates/reproducer_params.yml.j2 +++ b/roles/reproducer/templates/reproducer_params.yml.j2 @@ -1,6 +1,6 @@ --- # Generated by CI Framework reproducer -cifmw_openshift_kubeconfig: /home/zuul/.kube/config +cifmw_openshift_kubeconfig: {{ cifmw_reproducer_controller_user_dir }}/.kube/config cifmw_openshift_login_password: 12345678 {% if cifmw_reproducer_params | length > 0 -%} {{ cifmw_reproducer_params | to_nice_yaml }} diff --git a/roles/reproducer/vars/main.yml b/roles/reproducer/vars/main.yml index 64ebcbfe97..85cb23d566 100644 --- a/roles/reproducer/vars/main.yml +++ b/roles/reproducer/vars/main.yml @@ -2,11 +2,11 @@ # Default repositories we always want to have cifmw_reproducer_default_repositories: - src: "https://github.com/openstack-k8s-operators/ci-framework" - dest: "{{ cifmw_project_dir_absolute }}" + dest: "{{ cifmw_reproducer_controller_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework" - src: "https://github.com/openstack-k8s-operators/install_yamls" - dest: "{{ cifmw_installyamls_repos }}" + dest: "{{ cifmw_reproducer_controller_user_dir }}/src/github.com/openstack-k8s-operators/install_yamls" - src: "https://github.com/openstack-k8s-operators/architecture" - dest: "/home/zuul/src/github.com/openstack-k8s-operators/architecture" + dest: "{{ cifmw_reproducer_controller_user_dir }}/src/github.com/openstack-k8s-operators/architecture" # one place to rule them all cifmw_reproducer_nm_dnsmasq: "/etc/NetworkManager/conf.d/zz-dnsmasq.conf"