Skip to content

Commit

Permalink
add playbook pbench agent bootstrap and
Browse files Browse the repository at this point in the history
pbench_agent install
  • Loading branch information
asyedham committed Dec 16, 2020
1 parent 65764ef commit 07a27b3
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 23 deletions.
10 changes: 8 additions & 2 deletions install/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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
57 changes: 57 additions & 0 deletions install/pbench_agent_bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
#
# Playbook for installing pbench_bootstrap
#
# Usage:
# ansible-playbook pbench_agent_bootstrap.yml -e "repos=<perf-dept-repo>"

- 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: |
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 }}"
57 changes: 57 additions & 0 deletions install/pbench_agent_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
#
# Playbook for pbench agent installations
# Usage:
# ansible-playbook pbench_agent_install.yml

- hosts: compute
gather_facts: yes
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 }}"
11 changes: 10 additions & 1 deletion install/roles/create_vm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
29 changes: 10 additions & 19 deletions install/roles/network/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}"

7 changes: 6 additions & 1 deletion install/scripts/pass_auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ sed -i s/^PasswordAuthentication.*/PasswordAuthentication\ yes/ /etc/ssh/sshd_co
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
sudo dnf clean all
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
sudo dnf module install -y python36
sudo alternatives --set python /usr/bin/python3
sudo dnf --enablerepo=PowerTools install perl-Data-UUID -y

0 comments on commit 07a27b3

Please sign in to comment.