diff --git a/README.md b/README.md index c67c3af5..d338b555 100644 --- a/README.md +++ b/README.md @@ -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: + 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/group_vars/all.yml b/install/group_vars/all.yml index fb7be8b0..39c17965 100644 --- a/install/group_vars/all.yml +++ b/install/group_vars/all.yml @@ -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: +# 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//id_rsa_overcloud +#undercloud_hostname: #pbench_key_url: #pbench_config_url: #pbench_configuration_environment: "production" diff --git a/install/pbench_agent_bootstrap.yml b/install/pbench_agent_bootstrap.yml index 45af8547..a68a6436 100644 --- a/install/pbench_agent_bootstrap.yml +++ b/install/pbench_agent_bootstrap.yml @@ -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 }} diff --git a/install/pbench_agent_install.yml b/install/pbench_agent_install.yml index f380a972..ddbebdae 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,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: | @@ -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 }}" + 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..9b031135 100644 --- a/install/templates/repo_bootstrap.hosts.j2 +++ b/install/templates/repo_bootstrap.hosts.j2 @@ -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 %}