From 64c5ce858863771480983c0c2e392673ab45479d Mon Sep 17 00:00:00 2001 From: Asma Syed Hameed Date: Mon, 7 Dec 2020 17:49:01 +0530 Subject: [PATCH 1/2] Add support for Pbench installation To install Pbench agent on the compute nodes and vm's (i.e client and server),you have to follow the below steps and set the below params install/group_vars/all.yml `pbench_key_url: pbench_config_url: pbench_configuration_environment: ` `cd {{ ansible_user_dir}}/jetpack/install` 1) To create the client and server `ansible-playbook boot.yml` 2) Install Pbench agent bootstrapping `ansible-playbook pbench_agent_bootstrap.yml -e "repos=" ` 3) Install Pbench agent install `ansible-playbook pbench_agent_install.yml` --- README.md | 18 +++ install/ansible.cfg | 4 + install/boot_vms.yml | 108 ++++++++++++++++++ install/filter_plugins/install_filters.py | 10 ++ install/group_vars/all.yml | 34 ++++++ install/pbench_agent_bootstrap.yml | 59 ++++++++++ install/pbench_agent_install.yml | 96 ++++++++++++++++ install/roles/create_vm/tasks/main.yml | 19 +++ install/roles/flavors/tasks/main.yml | 8 ++ install/roles/flavors/vars/main.yml | 7 ++ install/roles/images/tasks/main.yml | 43 +++++++ install/roles/network/tasks/main.yml | 47 ++++++++ install/roles/network/vars/main.yml | 3 + install/templates/.pass_auth.sh.j2.swp | Bin 0 -> 12288 bytes install/templates/pass_auth.sh.j2 | 19 +++ install/templates/pbench_agent_install.yml.j2 | 15 +++ install/templates/repo_bootstrap.hosts.j2 | 19 +++ 17 files changed, 509 insertions(+) create mode 100644 install/ansible.cfg create mode 100644 install/boot_vms.yml create mode 100644 install/filter_plugins/install_filters.py create mode 100644 install/group_vars/all.yml create mode 100644 install/pbench_agent_bootstrap.yml create mode 100644 install/pbench_agent_install.yml create mode 100644 install/roles/create_vm/tasks/main.yml create mode 100644 install/roles/flavors/tasks/main.yml create mode 100644 install/roles/flavors/vars/main.yml create mode 100644 install/roles/images/tasks/main.yml create mode 100644 install/roles/network/tasks/main.yml create mode 100644 install/roles/network/vars/main.yml create mode 100644 install/templates/.pass_auth.sh.j2.swp create mode 100755 install/templates/pass_auth.sh.j2 create mode 100644 install/templates/pbench_agent_install.yml.j2 create mode 100644 install/templates/repo_bootstrap.hosts.j2 diff --git a/README.md b/README.md index b0b59a93..c67c3af5 100644 --- a/README.md +++ b/README.md @@ -184,3 +184,21 @@ For OSP deploy with Ceph using Composable Roles, After setting the above specifi Note: User can customize [internal.yml.j2](templates/internal.yml.j2) template for Ceph deployment based on their requirement if needed +2) set composable_roles: true true in group_vars/all.yml + +## Pbench agent Installations +To install Pbench agent on the compute nodes and vm's (i.e client and server),you have to follow the below steps and set the below params install/group_vars/all.yml + +`pbench_key_url: + pbench_config_url: + pbench_configuration_environment: ` + +`cd {{ ansible_user_dir}}/jetpack/install` + +1) To create the client and server + `ansible-playbook boot.yml` +2) Install Pbench agent bootstrapping + `ansible-playbook pbench_agent_bootstrap.yml -e "repos=" ` +3) Install Pbench agent install + `ansible-playbook pbench_agent_install.yml` + diff --git a/install/ansible.cfg b/install/ansible.cfg new file mode 100644 index 00000000..864961b1 --- /dev/null +++ b/install/ansible.cfg @@ -0,0 +1,4 @@ +[defaults] +host_key_checking = false +inventory = ~/.infrared/.workspaces/active/hosts +timeout = 120 diff --git a/install/boot_vms.yml b/install/boot_vms.yml new file mode 100644 index 00000000..39b3a507 --- /dev/null +++ b/install/boot_vms.yml @@ -0,0 +1,108 @@ +--- + +# Playbook to create client and server vm on Openstack +# +# ansible-playbook boot_vms.yml + +- hosts: undercloud + gather_facts: yes + become: true + vars: + vm_password: centos + external_network: public + pre_tasks: + - name: generate pass_auth.sh + template: + src: pass_auth.sh.j2 + dest: "{{ user_dir }}/pass_auth.sh" + mode: a+rwx + + - name: install packages + package: + name: "{{ item }}" + state: present + loop: + - wget + - libguestfs-tools + - sshpass + - libvirt + + - name: restart libvirt service + service: + name: libvirtd + state: restarted + + roles: + - images + - flavors + - network + - create_vm + + post_tasks: + - name: check router exists + shell: | + . {{ overcloudrc }} + openstack router list | grep 'r1' + register: router_exists + ignore_errors: yes + + - name: router + shell: | + . {{ overcloudrc }} + openstack router create r1 + cidr=10.0.0.0 + subnet_id=`openstack subnet list -c ID -c Subnet -f value | grep $cidr | cut -d' ' -f1` + neutron router-interface-add r1 $subnet_id + neutron router-gateway-set r1 {{ external_network }} + when: router_exists.stdout == "" + + - name: create floating ip for client and server + shell: | + . {{ overcloudrc }} + client_port_id=`openstack port show {{ ports[0] }} -c id -f value` + server_port_id=`openstack port show {{ ports[1] }} -c id -f value` + neutron floatingip-create --port-id $client_port_id {{ external_network }} + neutron floatingip-create --port-id $server_port_id {{ external_network }} + ignore_errors: yes + + - name: get floating ip of server and client + shell: | + . {{ overcloudrc }} + openstack server list | grep {{ item }} | cut -d \| -f 5 | cut -d \, -f 2 | awk '{$1=$1;print}' + register: vms_fip + with_items: + - "{{ vm_names }}" + + - name: get computes ip + shell: | + . {{ stackrc }} + nova list | grep {{ item }} | cut -d \| -f 7 |cut -d \= -f 2 | awk '{$1=$1;print}' + register: computes_ip + with_items: + - "{{ compute_names }}" + + - name: update user to root + lineinfile: + path: "{{ user_dir}}/.ssh/config" + regexp: ' User heat-admin' + line: ' User root' + + - name: copy the ssh keys + shell: | + . {{ overcloudrc }} + echo '{{ vm_password }}' | sshpass ssh-copy-id -i {{ user_dir }}/.ssh/id_rsa -o 'StrictHostKeyChecking no' -f root@{{ item.stdout }} + with_items: "{{ vms_fip.results }}" + changed_when: false + + - name: get default route + shell: | + ip r | grep default | cut -d ' ' -f5 + register: default_route + + - name: flush iptables on undercloud and add masquerade rule + become: true + shell: | + iptables -F + iptables -t nat -L --line-numbers + iptables -t nat -A POSTROUTING -o {{ default_route.stdout }} -j MASQUERADE + iptables -t nat -A POSTROUTING -o br-ctlplane -j MASQUERADE diff --git a/install/filter_plugins/install_filters.py b/install/filter_plugins/install_filters.py new file mode 100644 index 00000000..a449e577 --- /dev/null +++ b/install/filter_plugins/install_filters.py @@ -0,0 +1,10 @@ +def dict_remove_item( dict, item): + """Remove an item from a dictionary.""" + del dict[item] + return dict + +class FilterModule(object): + def filters(self): + return { + 'dict_remove_item': dict_remove_item, + } diff --git a/install/group_vars/all.yml b/install/group_vars/all.yml new file mode 100644 index 00000000..fb7be8b0 --- /dev/null +++ b/install/group_vars/all.yml @@ -0,0 +1,34 @@ +--- +guest_image_name: pbench_image +# user can add the guest_image url required below +guest_images: + pbench_image: + name: pbench_image + url_centos8: http://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.2.2004-20200611.2.x86_64.qcow2 + url_centos7: http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 + type: qcow2 + convert_to_raw: false + +# rhel 8 +epel_repo: + el8: https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + el7: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + +pbench_image_rhel: false + +compute_names: ['compute-0', 'compute-1' ] + +#name for the client and server +vm_names: [ client, server ] + +user_dir: /home/stack +overcloudrc: /home/stack/overcloudrc +stackrc: /home/stack/stackrc +# port names +ports: [ 'client_port', 'server_port'] +timeout: 30 + +# update the values to install pbench agent +#pbench_key_url: +#pbench_config_url: +#pbench_configuration_environment: "production" diff --git a/install/pbench_agent_bootstrap.yml b/install/pbench_agent_bootstrap.yml new file mode 100644 index 00000000..45af8547 --- /dev/null +++ b/install/pbench_agent_bootstrap.yml @@ -0,0 +1,59 @@ +--- +# +# Playbook for installing pbench_bootstrap +# +# Usage: +# ansible-playbook pbench_agent_bootstrap.yml -e "repos=" + +- hosts: compute + tasks: + - name: copy the keys + shell: | + sudo cp -r ~/.ssh /root/ + +- hosts: undercloud + gather_facts: yes + tasks: + - name: clone perf-dept + shell: | + GIT_SSL_NO_VERIFY=true git clone {{ repos }} + ignore_errors: yes + + - name: get computes ip + shell: | + . {{ stackrc }} + nova list | grep {{ item }} | cut -d \| -f 7 |cut -d \= -f 2 | awk '{$1=$1;print}' + register: computes_ip + with_items: + - "{{ compute_names }}" + + - name: get floating ip of server and client + shell: | + . {{ overcloudrc }} + openstack server list | grep {{ item }} | cut -d \| -f 5 | cut -d \, -f 2 | awk '{$1=$1;print}' + register: vms_fip + with_items: + - "{{ vm_names }}" + + - name: copy the keys + shell: | + sudo cp -r ~/.ssh /root/ + + - name: create inventories + file: + path: "{{ user_dir }}/.config/Inventories/" + state: directory + + - name: generate a inventory + template: + src: repo_bootstrap.hosts.j2 + dest: "{{ user_dir }}/.config/Inventories/repo-bootstrap.hosts" + + - name: run repo-bootstrap.yml + shell: | + ansible-playbook --user=root -i "{{ user_dir}}/.config/Inventories/repo-bootstrap.hosts" repo-bootstrap.yml + register: repo_bootstrap + args: + chdir: "{{ user_dir }}/perf-dept/sysadmin/Ansible" + - debug: + msg: "{{ repo_bootstrap }}" diff --git a/install/pbench_agent_install.yml b/install/pbench_agent_install.yml new file mode 100644 index 00000000..f380a972 --- /dev/null +++ b/install/pbench_agent_install.yml @@ -0,0 +1,96 @@ +--- +# +# Playbook for pbench agent installations +# Usage: +# ansible-playbook pbench_agent_install.yml + +- hosts: compute + gather_facts: yes + tasks: + - name: install latest epel-release + yum: + name: "{{ epel_repo.el7 }}" + state: present + become: yes + loop: + - "{{ epel_repo.el7 }}" + - perl-Data-UUID + when: ansible_distribution_major_version < '8' + + - name: install perl-Data-UUID on Compute nodes + become: true + dnf: + name: perl-Data-UUID + state: present + when: ansible_distribution_major_version == '8' + +- hosts: undercloud + vars: + pbench_agent_install: true + + tasks: + - block: + - name: remove old epel-release + yum: + name: "{{item }}" + state: absent + become: yes + ignore_errors: yes + loop: + - epel-release + - ansible + + - name: install latest epel-release + yum: + name: "{{ epel_repo.el7 }}" + state: present + become: yes + + - name: install ansible 2.9 + yum: + name: ansible + state: present + become: yes + + when: ansible_distribution_major_version < '8' + + + - name: Install the pbench-agent roles from Galaxy + shell: | + ansible-galaxy collection install pbench.agent + export ANSIBLE_ROLES_PATH=$HOME/.ansible/collections/ansible_collections/pbench/agent/roles:$ANSIBLE_ROLES_PATH + + - name: generate pbench agent playbook + template: + src: pbench_agent_install.yml.j2 + dest: "{{ user_dir }}/.ansible/collections/ansible_collections/pbench/agent/roles/pbench_agent_install.yml" + + - name: get computes ip + shell: | + . {{ stackrc }} + nova list | grep {{ item }} | cut -d \| -f 7 |cut -d \= -f 2 | awk '{$1=$1;print}' + register: computes_ip + with_items: + - "{{ compute_names }}" + + - name: get floating ip of server and client + shell: | + . {{ overcloudrc }} + openstack server list | grep {{ item }} | cut -d \| -f 5 | cut -d \, -f 2 | awk '{$1=$1;print}' + register: vms_fip + with_items: + - "{{ vm_names }}" + + - name: create a inventory file + template: + src: repo_bootstrap.hosts.j2 + dest: "{{ user_dir }}/.config/myhosts.inv" + + - name: run the playbook pbench_agent_install.yml + shell: | + ansible-playbook -i ~/.config/myhosts.inv pbench_agent_install.yml + register: agent_install + args: + chdir: "{{ user_dir }}/.ansible/collections/ansible_collections/pbench/agent/roles/" + - debug: + msg: "{{ agent_install }}" diff --git a/install/roles/create_vm/tasks/main.yml b/install/roles/create_vm/tasks/main.yml new file mode 100644 index 00000000..02a28d09 --- /dev/null +++ b/install/roles/create_vm/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: create a vm's + shell: . {{ overcloudrc }}; openstack server create --flavor pbench_flavor --image {{ guest_image_name }} --nic port-id={{ item[0].stdout }} --user-data {{ user_dir }}/pass_auth.sh {{ item[1] }} + with_together: + - "{{ port_ids.results }}" + - "{{ vm_names }}" + ignore_errors: yes + +- name: create a vm's + shell: . {{ overcloudrc }}; openstack server create --flavor pbench_flavor --image {{ guest_image_name }} --nic port-id={{ item[0].stdout }} --user-data {{ user_dir }}/pass_auth.sh {{ item[1] }} + with_together: + - "{{ get_port_ids.results }}" + - "{{ vm_names }}" + ignore_errors: yes + + +- name: wait for vm to boot + wait_for: + timeout: "{{ timeout }}" diff --git a/install/roles/flavors/tasks/main.yml b/install/roles/flavors/tasks/main.yml new file mode 100644 index 00000000..aa187fa4 --- /dev/null +++ b/install/roles/flavors/tasks/main.yml @@ -0,0 +1,8 @@ +--- +# Add flavors to OpenStack Cloud +# Ignore errors here incase the flavors already exist. + +- name: Add flavors to overcloud + shell: . {{ overcloudrc }}; openstack flavor create --public {{ item.name }} --id auto --ram {{ item.ram }} --disk {{ item.disk }} --vcpus {{ item.cpu }} + with_items: "{{ pbench_flavors }}" + ignore_errors: true diff --git a/install/roles/flavors/vars/main.yml b/install/roles/flavors/vars/main.yml new file mode 100644 index 00000000..b6a04345 --- /dev/null +++ b/install/roles/flavors/vars/main.yml @@ -0,0 +1,7 @@ +--- +pbench_flavors: + - name: pbench_flavor + cpu: 8 + disk: 160 + ram: 16384 + diff --git a/install/roles/images/tasks/main.yml b/install/roles/images/tasks/main.yml new file mode 100644 index 00000000..dea31e5f --- /dev/null +++ b/install/roles/images/tasks/main.yml @@ -0,0 +1,43 @@ +--- +# Obtain/Upload guest_images to OpenStack Cloud + +- name: Fetch image + get_url: + url: "{{ guest_images[item].url_centos7 }}" + dest: "/home/stack/{{ guest_images[item].name }}.{{ guest_images[item].type }}" + with_items: "{{ guest_images }}" + when: ansible_distribution_major_version < '8' + +- name: Fetch image + get_url: + url: "{{ guest_images[item].url_centos8 }}" + dest: "/home/stack/{{ guest_images[item].name }}.{{ guest_images[item].type }}" + with_items: "{{ guest_images }}" + when: ansible_distribution_major_version == '8' + +- name: Determine if image exists + shell: . {{ overcloudrc }}; openstack image list | grep '{{ guest_images[item].name }}' + register: image_exists + ignore_errors: true + changed_when: false + with_items: "{{ guest_images }}" + +- name: Remove image from dictionary of images if image exists + set_fact: + guest_images: "{{ guest_images|dict_remove_item(item[0]) }}" + when: item[0] in item[1].stdout and + item[1] is defined + with_nested: + - "{{ guest_images }}" + - "{{ image_exists.results }}" + +- name: change the root password for qcow2 image + shell: | + export LIBGUESTFS_BACKEND=direct + virt-customize -a {{user_dir }}/{{ guest_images[item].name }}.{{ guest_images[item].type }} --root-password password:"{{ vm_password }}" + with_items: "{{ guest_images }}" + +- name: Upload image into cloud + shell: . {{ overcloudrc }}; openstack image create --public --disk-format={{ guest_images[item].type }} --container-format=bare {{ guest_images[item].name }} < {{ user_dir }}/{{ guest_images[item].name }}.{{ guest_images[item].type }} + ignore_errors: true + with_items: "{{ guest_images }}" diff --git a/install/roles/network/tasks/main.yml b/install/roles/network/tasks/main.yml new file mode 100644 index 00000000..f55d75f9 --- /dev/null +++ b/install/roles/network/tasks/main.yml @@ -0,0 +1,47 @@ +--- + +#Create a network, subnet, ports for client and server vms + +- name: Determine if network exists + shell: . {{ overcloudrc }}; openstack network list | grep '{{ network_name }}' + register: network_exists + ignore_errors: true + +- name: create a network + shell: . {{ overcloudrc }}; neutron net-create '{{ network_name }}' | egrep '\sid\s' | awk '{print $4}' + register: network_id + +- name: get dns server + shell: | + cat /etc/resolv.conf | grep nameserver | head -n1 | cut -d ' ' -f2 + register: dns_server + +- name: create subnet + shell: . {{ overcloudrc }}; neutron subnet-create --dns-nameserver {{ dns_server.stdout }} {{ network_id.stdout }} 10.0.0.0/24 + ignore_errors: yes + +- name: Determine if ports exists + shell: . {{ overcloudrc }}; openstack port list | grep '{{ item }}' + register: port_exists + with_items: "{{ ports }}" + ignore_errors: true + +- name: Create ports for client and server + shell: | + . {{ overcloudrc }} + openstack port create --no-security-group --disable-port-security --network {{ network_id.stdout }} {{ item.0 }} | egrep '\sid\s' | awk '{print $4}' + register: port_ids + when: item.1.stdout == "" + with_together: + - "{{ ports }}" + - "{{ port_exists.results }}" + +- name: get port ids for client and server + shell: | + . {{ overcloudrc }} + openstack port list | grep "{{ item.0 }}" | cut -d \| -f 2 | awk '{$1=$1;print}' + register: get_port_ids + when: item.1.stdout != "" + with_together: + - "{{ ports }}" + - "{{ port_exists.results }}" diff --git a/install/roles/network/vars/main.yml b/install/roles/network/vars/main.yml new file mode 100644 index 00000000..f23a46a7 --- /dev/null +++ b/install/roles/network/vars/main.yml @@ -0,0 +1,3 @@ +--- + +network_name: pbench_network diff --git a/install/templates/.pass_auth.sh.j2.swp b/install/templates/.pass_auth.sh.j2.swp new file mode 100644 index 0000000000000000000000000000000000000000..49efbbcff44b0f901ebc80e7f86ad445193c9231 GIT binary patch literal 12288 zcmeI&PiqrF6aet4;IS(9B6xXC=|$L`CIQVQhe8E=DD=>H5HU=4UfivdnPq0uu!N{L z{S<`hS;knKHQxFk9ivM^t{)SieIq+3*1Iv9;eA*d(`iB59(!mon6>@IJ!*+p34F(zyd750xZA+ zEWiRRu;Bu++!7zChC59i_nUF+ud#XLfdyEA1z3OuSbzmsfCX591z3OuSYQJMlosOW zwh)K+=q!O7WTEgkqg%10DFtEWiRR zzyd750xZA+EWiRRzykjkST6SgtuCgpzY<}t9cVj+Btfet20fN;cnpSTp z(VOH*MU{+3$48J Date: Thu, 24 Dec 2020 16:46:35 +0530 Subject: [PATCH 2/2] install pbench agent on trafficgen host --- README.md | 20 ++++- install/boot_vms.yml | 8 -- install/group_vars/all.yml | 19 +++-- install/pbench_agent_bootstrap.yml | 12 ++- install/pbench_agent_install.yml | 96 ++++++++++++----------- install/roles/images/tasks/main.yml | 4 +- install/templates/my.hosts.j2 | 25 ++++++ install/templates/pass_auth.sh.j2 | 0 install/templates/repo_bootstrap.hosts.j2 | 13 +-- 9 files changed, 119 insertions(+), 78 deletions(-) create mode 100644 install/templates/my.hosts.j2 mode change 100755 => 100644 install/templates/pass_auth.sh.j2 diff --git a/README.md b/README.md index c67c3af5..d95521ff 100644 --- a/README.md +++ b/README.md @@ -189,14 +189,28 @@ Note: User can customize [internal.yml.j2](templates/internal.yml.j2) template f ## Pbench agent Installations To install Pbench agent on the compute nodes and vm's (i.e client and server),you have to follow the below steps and set the below params install/group_vars/all.yml -`pbench_key_url: +``` + pbench_key_url: pbench_config_url: - pbench_configuration_environment: ` + + #check the infrared inv to update the value + id_rsa_overcloud: ~/.infrared/.workspaces//id_rsa_overcloud + undercloud_hostname: +``` `cd {{ ansible_user_dir}}/jetpack/install` 1) To create the client and server - `ansible-playbook boot.yml` + `ansible-playbook boot_vms.yml` + +To install Pbench agent on Trafficgen host, set the below params + +``` +trafficgen_host: + ip: + ssh_pass: password + ssh_user: root +``` 2) Install Pbench agent bootstrapping `ansible-playbook pbench_agent_bootstrap.yml -e "repos=" ` 3) Install Pbench agent install diff --git a/install/boot_vms.yml b/install/boot_vms.yml index 39b3a507..77e77087 100644 --- a/install/boot_vms.yml +++ b/install/boot_vms.yml @@ -73,14 +73,6 @@ with_items: - "{{ vm_names }}" - - name: get computes ip - shell: | - . {{ stackrc }} - nova list | grep {{ item }} | cut -d \| -f 7 |cut -d \= -f 2 | awk '{$1=$1;print}' - register: computes_ip - with_items: - - "{{ compute_names }}" - - name: update user to root lineinfile: path: "{{ user_dir}}/.ssh/config" diff --git a/install/group_vars/all.yml b/install/group_vars/all.yml index fb7be8b0..b2e1f480 100644 --- a/install/group_vars/all.yml +++ b/install/group_vars/all.yml @@ -16,19 +16,26 @@ epel_repo: pbench_image_rhel: false -compute_names: ['compute-0', 'compute-1' ] - #name for the client and server vm_names: [ client, server ] +# port names +ports: [ 'client_port', 'server_port'] +timeout: 15 + +# trafficgen host ip address +#trafficgen_host: +# ip: +# ssh_pass: password +# ssh_user: root user_dir: /home/stack overcloudrc: /home/stack/overcloudrc stackrc: /home/stack/stackrc -# port names -ports: [ 'client_port', 'server_port'] -timeout: 30 # update the values to install pbench agent +#check the infrared inv +#id_rsa_overcloud: ~/.infrared/.workspaces//id_rsa_overcloud +#undercloud_hostname: #pbench_key_url: #pbench_config_url: -#pbench_configuration_environment: "production" +pbench_configuration_environment: "production" diff --git a/install/pbench_agent_bootstrap.yml b/install/pbench_agent_bootstrap.yml index 45af8547..fd54b015 100644 --- a/install/pbench_agent_bootstrap.yml +++ b/install/pbench_agent_bootstrap.yml @@ -19,13 +19,19 @@ GIT_SSL_NO_VERIFY=true git clone {{ repos }} ignore_errors: yes + - name: copy keys to trafficgen host + shell: | + echo '{{ trafficgen_host.ssh_pass }}' | sshpass ssh-copy-id -i ~/.ssh/id_rsa -o 'StrictHostKeyChecking no' -f {{ trafficgen_host.ssh_user }}@{{ trafficgen_host.ip }} + register: ssh_result + changed_when: false + ignore_errors: true + when: trafficgen_host is defined + - name: get computes ip shell: | . {{ stackrc }} - nova list | grep {{ item }} | cut -d \| -f 7 |cut -d \= -f 2 | awk '{$1=$1;print}' + nova list | grep -i "compute" | cut -d \| -f 7 |cut -d \= -f 2 | awk '{$1=$1;print}' register: computes_ip - with_items: - - "{{ compute_names }}" - name: get floating ip of server and client shell: | diff --git a/install/pbench_agent_install.yml b/install/pbench_agent_install.yml index f380a972..01619a83 100644 --- a/install/pbench_agent_install.yml +++ b/install/pbench_agent_install.yml @@ -1,13 +1,9 @@ ---- -# -# Playbook for pbench agent installations -# Usage: # ansible-playbook pbench_agent_install.yml - hosts: compute gather_facts: yes tasks: - - name: install latest epel-release + - name: install latest epel and perl-Data-UUID yum: name: "{{ epel_repo.el7 }}" state: present @@ -25,35 +21,31 @@ when: ansible_distribution_major_version == '8' - hosts: undercloud + gather_facts: yes + tasks: + - name: get floating ip of server and client + shell: | + . {{ overcloudrc }} + openstack server list | grep {{ item }} | cut -d \| -f 5 | cut -d \, -f 2 | awk '{$1=$1;print}' + register: vms_fip + with_items: + - "{{ vm_names }}" + +- hosts: localhost vars: pbench_agent_install: true + vms_fip: "{{ hostvars['undercloud']['vms_fip'] }}" + host_file: "{{ ansible_user_dir }}/.config/hosts" + infrared_inv: "{{ ansible_user_dir }}/.infrared/.workspaces/active/hosts" tasks: - - block: - - name: remove old epel-release - yum: - name: "{{item }}" - state: absent - become: yes - ignore_errors: yes - loop: - - epel-release - - ansible - - - name: install latest epel-release - yum: - name: "{{ epel_repo.el7 }}" - state: present - become: yes - - - name: install ansible 2.9 - yum: - name: ansible - state: present - become: yes - - when: ansible_distribution_major_version < '8' - + - name: copy keys to trafficgen host + shell: | + echo '{{ trafficgen_host.ssh_pass }}' | sshpass ssh-copy-id -i ~/.ssh/id_rsa -o 'StrictHostKeyChecking no' -f {{ trafficgen_host.ssh_user }}@{{ trafficgen_host.ip }} + register: ssh_result + changed_when: false + ignore_errors: true + when: trafficgen_host is defined - name: Install the pbench-agent roles from Galaxy shell: | @@ -63,34 +55,44 @@ - name: generate pbench agent playbook template: src: pbench_agent_install.yml.j2 - dest: "{{ user_dir }}/.ansible/collections/ansible_collections/pbench/agent/roles/pbench_agent_install.yml" + dest: "{{ ansible_user_dir }}/.ansible/collections/ansible_collections/pbench/agent/roles/pbench_agent_install.yml" - - name: get computes ip - shell: | - . {{ stackrc }} - nova list | grep {{ item }} | cut -d \| -f 7 |cut -d \= -f 2 | awk '{$1=$1;print}' - register: computes_ip - with_items: - - "{{ compute_names }}" + - name: create .config dir + file: + path: "{{ ansible_user_dir }}/.config/" + state: directory - - name: get floating ip of server and client + - name: copy the infrared inv in ~/.config shell: | - . {{ overcloudrc }} - openstack server list | grep {{ item }} | cut -d \| -f 5 | cut -d \, -f 2 | awk '{$1=$1;print}' - register: vms_fip - with_items: + cp {{ infrared_inv }} {{ host_file }} + + - name: Add client and server in inventory + blockinfile: + path: "{{ host_file }}" + marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item[0] }}" + regexp: "[local]" + block: | + {{ item[0] }} original_name= ansible_host={{ item[1].stdout }} ansible_connection=ssh ansible_user=root ansible_ssh_private_key_file={{ id_rsa_overcloud }} ansible_ssh_common_args='-o ProxyCommand="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -W %h:%p -i {{ ansible_user_dir }}/.ssh/id_rsa stack@{{ undercloud_hostname }}"' + with_together: - "{{ vm_names }}" + - "{{ vms_fip.results }}" - name: create a inventory file template: - src: repo_bootstrap.hosts.j2 - dest: "{{ user_dir }}/.config/myhosts.inv" + src: my.hosts.j2 + dest: "{{ ansible_user_dir }}/.config/myhosts.inv" + + - name: generate a pbench_agent_install inv + shell: | + cat "{{ ansible_user_dir }}/.config/myhosts.inv" >> {{ host_file }} - name: run the playbook pbench_agent_install.yml shell: | - ansible-playbook -i ~/.config/myhosts.inv pbench_agent_install.yml + export ANSIBLE_HOST_KEY_CHECKING=False + ansible-playbook -i {{ host_file }} pbench_agent_install.yml -T {{ timeout }} --user=root register: agent_install args: - chdir: "{{ user_dir }}/.ansible/collections/ansible_collections/pbench/agent/roles/" + chdir: "{{ ansible_user_dir }}/.ansible/collections/ansible_collections/pbench/agent/roles/" - debug: msg: "{{ agent_install }}" + diff --git a/install/roles/images/tasks/main.yml b/install/roles/images/tasks/main.yml index dea31e5f..16724010 100644 --- a/install/roles/images/tasks/main.yml +++ b/install/roles/images/tasks/main.yml @@ -1,14 +1,14 @@ --- # Obtain/Upload guest_images to OpenStack Cloud -- name: Fetch image +- name: Fetch image centos7 get_url: url: "{{ guest_images[item].url_centos7 }}" dest: "/home/stack/{{ guest_images[item].name }}.{{ guest_images[item].type }}" with_items: "{{ guest_images }}" when: ansible_distribution_major_version < '8' -- name: Fetch image +- name: Fetch image centos8 get_url: url: "{{ guest_images[item].url_centos8 }}" dest: "/home/stack/{{ guest_images[item].name }}.{{ guest_images[item].type }}" diff --git a/install/templates/my.hosts.j2 b/install/templates/my.hosts.j2 new file mode 100644 index 00000000..4318aa50 --- /dev/null +++ b/install/templates/my.hosts.j2 @@ -0,0 +1,25 @@ +[vms] +{% for item in vm_names %} +{{ item }} +{% endfor %} + +{% if trafficgen_host is defined %} +[trafficgen_host] +{{ trafficgen_host.ip }} +{% endif %} + +[servers:children] +compute +vms +{% if trafficgen_host is defined %} +trafficgen_host +{% endif %} + +{% if pbench_agent_install|default(false) %} +[servers:vars] +# where to get the key +pbench_key_url = {{ pbench_key_url }} + +# where to get the config file +pbench_config_url = {{ pbench_config_url }} +{% endif %} diff --git a/install/templates/pass_auth.sh.j2 b/install/templates/pass_auth.sh.j2 old mode 100755 new mode 100644 diff --git a/install/templates/repo_bootstrap.hosts.j2 b/install/templates/repo_bootstrap.hosts.j2 index df9f33d9..707ac930 100644 --- a/install/templates/repo_bootstrap.hosts.j2 +++ b/install/templates/repo_bootstrap.hosts.j2 @@ -5,15 +5,10 @@ {{ item.stdout }} {% endfor %} {% endif %} -{% for item in computes_ip.results %} -{{ item.stdout }} +{% for item in computes_ip.stdout_lines%} +{{ item }} {% endfor %} -{% if pbench_agent_install|default(false) %} -[servers:vars] -# where to get the key -pbench_key_url = {{ pbench_key_url }} - -# where to get the config file -pbench_config_url = {{ pbench_config_url }} +{% if trafficgen_host is defined %} +{{ trafficgen_host.ip }} {% endif %}