diff --git a/install/group_vars/all.yml b/install/group_vars/all.yml index 4f4eb5af..cdd8002f 100644 --- a/install/group_vars/all.yml +++ b/install/group_vars/all.yml @@ -8,6 +8,8 @@ guest_images: type: qcow2 convert_to_raw: false +pbench_image_rhel: false + # user can specify the hypervisor on which he wants to create client and server vm's hypervisor_hostnames: [ 'compute-0.redhat.local', 'compute-1.redhat.local'] @@ -18,8 +20,12 @@ vm_names: [ client, server ] overcloudrc: /home/stack/overcloudrc +# port names ports: [ 'client_port', 'server_port'] +timeout: 30 -dns_nameserver: 10.1.32.3 +# update the values to install pbench agent +#pbench_key_url: +#pbench_config_url: +#pbench_configuration_environment: "production" -timeout: 30 diff --git a/install/pbench_agent_bootstrap.yml b/install/pbench_agent_bootstrap.yml new file mode 100644 index 00000000..92c3f455 --- /dev/null +++ b/install/pbench_agent_bootstrap.yml @@ -0,0 +1,58 @@ +--- +# +# Playbook for installing pbench_bootstrap +# +# Usage: +# ansible-playbook pbench_agent_bootstrap.yml -e "repos=" + +- hosts: compute + gather_facts: yes + 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: | + source /home/stack/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: | + source /home/stack/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 }}" + shell: | + sudo cp -r ~/.ssh /root/ + + - name: create inventories + file: + path: ~/.config/Inventories/ + state: directory + + - name: generate a inventory + template: + src: repo_bootstrap.hosts.j2 + dest: /home/stack/.config/Inventories/repo-bootstrap.hosts + + - name: run repo-bootstrap.yml + shell: | + ansible-playbook --user=root -i /home/stack/.config/Inventories/repo-bootstrap.hosts repo-bootstrap.yml + register: repo_bootstrap + args: + chdir: /home/stack/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..6c641abc --- /dev/null +++ b/install/pbench_agent_install.yml @@ -0,0 +1,56 @@ +--- +# +# Playbook for pbench agent installations +# Usage: +# ansible-playbook pbench_agent_install.yml + +- hosts: compute + tasks: + - name: install perl-Data-UUID on Compute nodes + shell: | + sudo dnf install perl-Data-UUID -y + +- hosts: undercloud + vars: + pbench_agent_install: true + + tasks: + - 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: /home/stack/.ansible/collections/ansible_collections/pbench/agent/roles/pbench_agent_install.yml + + - name: get computes ip + shell: | + source /home/stack/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: | + source /home/stack/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: /home/stack/.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: /home/stack/.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 index 2996ed24..4feafd10 100644 --- a/install/roles/create_vm/tasks/main.yml +++ b/install/roles/create_vm/tasks/main.yml @@ -3,10 +3,19 @@ shell: . {{ overcloudrc }}; openstack server create --hypervisor-hostname {{ item[0] }} --flavor pbench_flavor --image {{ guest_image_name }} --nic port-id={{ item[1].stdout }} --user-data /home/stack/pass_auth.sh {{ item[2] }} with_together: - "{{ hypervisor_hostnames }}" - - "{{ port_ids }}" + - "{{ port_ids.results }}" - "{{ vm_names }}" ignore_errors: yes +- name: create a vm's on specified hypervisors + shell: . {{ overcloudrc }}; openstack server create --hypervisor-hostname {{ item[0] }} --flavor pbench_flavor --image {{ guest_image_name }} --nic port-id={{ item[1].stdout }} --user-data /home/stack/pass_auth.sh {{ item[2] }} + with_together: + - "{{ hypervisor_hostnames }}" + - "{{ get_port_ids.results }}" + - "{{ vm_names }}" + ignore_errors: yes + + - name: wait for vm to boot wait_for: timeout: "{{ timeout }}" diff --git a/install/roles/network/tasks/main.yml b/install/roles/network/tasks/main.yml index 8bcb8f76..f55d75f9 100644 --- a/install/roles/network/tasks/main.yml +++ b/install/roles/network/tasks/main.yml @@ -7,16 +7,17 @@ register: network_exists ignore_errors: true -- debug: - msg: "{{ network_exists }}" - - name: create a network shell: . {{ overcloudrc }}; neutron net-create '{{ network_name }}' | egrep '\sid\s' | awk '{print $4}' register: network_id - when: network_exists.stdout == "" + +- 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_nameserver }} {{ network_name }} 10.0.0.0/24 + 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 @@ -30,27 +31,17 @@ . {{ 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 == "" + 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: port_ids - when: item[1].stdout != "" + 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 }}" - - -- debug: - msg: "{{ port_ids.results }}" - -- name: set fact for port ids - set_fact: - port_ids: "{{ port_ids.results }}" - diff --git a/install/scripts/pass_auth.sh b/install/scripts/pass_auth.sh index 69cbb760..86af30e0 100755 --- a/install/scripts/pass_auth.sh +++ b/install/scripts/pass_auth.sh @@ -5,3 +5,7 @@ systemctl restart sshd cat /etc/ssh/sshd_config echo "Enabled PasswordAuthentication" dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y +dnf module install -y python36 +alternatives --set python /usr/bin/python3 +dnf --enablerepo=PowerTools install perl-Data-UUID -y +