Skip to content

Commit

Permalink
install pbench agent on trafficgen host
Browse files Browse the repository at this point in the history
  • Loading branch information
asyedham committed Jan 20, 2021
1 parent 64c5ce8 commit 8492e26
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 59 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ To install Pbench agent on the compute nodes and vm's (i.e client and server),yo

1) To create the client and server
`ansible-playbook boot.yml`

To install Pbench agent on Trafficgen host, set the below params

trafficgen_host:
ip: <ip>
ssh_pass: password
ssh_user: root

2) Install Pbench agent bootstrapping
`ansible-playbook pbench_agent_bootstrap.yml -e "repos=<perf-dept-repo>" `
3) Install Pbench agent install
Expand Down
15 changes: 12 additions & 3 deletions install/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@ 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: <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 for id_rsa_overcloud
#id_rsa_overcloud: ~/.infrared/.workspaces/<update_value>/id_rsa_overcloud
#undercloud_hostname:
#pbench_key_url:
#pbench_config_url:
#pbench_configuration_environment: "production"
8 changes: 8 additions & 0 deletions install/pbench_agent_bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
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 }}
Expand Down
105 changes: 58 additions & 47 deletions install/pbench_agent_install.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,35 +21,40 @@
when: ansible_distribution_major_version == '8'

- hosts: undercloud
vars:
pbench_agent_install: true

gather_facts: yes
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: 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: install ansible 2.9
yum:
name: ansible
state: present
become: 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 }}"

when: ansible_distribution_major_version < '8'
- hosts: localhost
vars:
pbench_agent_install: true
computes_ip: "{{ hostvars['undercloud']['computes_ip'] }}"
vms_fip: "{{ hostvars['undercloud']['vms_fip'] }}"
host_file: "{{ ansible_user_dir }}/.config/hosts"
infrared_inv: "{{ ansible_user_dir }}/.infrared/.workspaces/active/hosts"

tasks:
- 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: |
Expand All @@ -63,34 +64,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 }}"

4 changes: 2 additions & 2 deletions install/roles/images/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
Expand Down
25 changes: 25 additions & 0 deletions install/templates/my.hosts.j2
Original file line number Diff line number Diff line change
@@ -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 %}
Empty file modified install/templates/pass_auth.sh.j2
100755 → 100644
Empty file.
9 changes: 2 additions & 7 deletions install/templates/repo_bootstrap.hosts.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
{{ item.stdout }}
{% 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 %}

0 comments on commit 8492e26

Please sign in to comment.