Skip to content

Commit 1d21d5a

Browse files
committed
Rework pbench-agent ansible playbooks
Rework the ansible playbooks to make them as similar as possible to the server ansible playbooks (PR#1199). In particular, fix the config and ssh key install to allow hosts outside the firewall to be configured (as long as the ansible host is inside). Usage: ansible-playbook --user=root -i /path/to/inventory.file \ pbench-agent-install.yml \ [ --extra-vars='{cenv: <environment>}' ] Two other playbooks use subsets of the defined roles: pbench-repo-install.yml installs the COPR repos only. You can then install the pbench-agent RPM manually. In that case, the third playbook can be used to install the config and key files afterwards. An example inventory file, Inventory/pbench-agent.hosts.example, is provided. The second section of the file contains the definition of various variables that are used by the playbooks. These are set to dummy values here, so a site admin should modify this file for a particular installation and make it available to the users for that site. Users should then copy and mofify the example file, without touching the variables section: they should just add their hosts to the first section (possibly augmented with host varirable definitions, e.g. ansible_python_interpreter, that might be need to work around problems on some distros).
1 parent 946ccc1 commit 1d21d5a

File tree

19 files changed

+218
-41
lines changed

19 files changed

+218
-41
lines changed

agent/ansible/Inventory/pbench-agent.hosts

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Users should copy the site-specific file and modify *only* the
2+
# first section by adding their hosts. They may also need to
3+
# provide host-specific variables to deal with problems (e.g ATM,
4+
# a F30 host needs to have the `ansible_python_interpreter' variable
5+
# to /usr/bin/python3 in order for things to work - see host3 below
6+
# as an example.)
7+
[servers]
8+
host1
9+
host2
10+
host3 ansible_python_interpreter=/usr/bin/python3
11+
12+
# This section contains site-specific variables. An admin should
13+
# modify these settings and provide the resulting file as a site-specific
14+
# example. Once that is done, users should *NOT* have to modify this section at all.
15+
[servers:vars]
16+
pbench_repo_url_prefix = https://copr-be.cloud.fedoraproject.org/results/<EXAMPLE_USER>
17+
18+
# where to get the key
19+
pbench_key_url = http://EXAMPLE.COM/PATH/TO/agent/{{ cenv }}/ssh
20+
# where to put it
21+
pbench_key_dest = /opt/pbench-agent/
22+
23+
# where to get the config file
24+
pbench_config_url = http://EXAMPLE.COM/PATH/TO/agent/{{ cenv }}/config
25+
# where to put it
26+
pbench_config_dest = /opt/pbench-agent/config/
27+
28+
pbench_config_files = '["pbench-agent.cfg"]'
29+
30+
owner = pbench
31+
group = pbench

agent/ansible/README

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
* Ansible playbook to install key and config file
1+
* Ansible playbooks to install pbench-agent
22

3-
We assume that the pbench-agent code has been installed (through a
4-
package or some other method). That installation is incomplete until
5-
we install a key file so that =pbench=-move/copy-results= can
6-
move/copy results to the server and a config file so that it knows
7-
which server to use.
3+
The basic playbook is pbench-agent-install.yml which
84

9-
The =pbench-agent-config.yml= playbook does that, by using variables
10-
defined in the inventory file (for an example inventory file, see
11-
=Inventory/pbench-agent.hosts=).
5+
- installs the pbench agent repo.
6+
- installs the pbench-agent RPM.
7+
- installs the config file(s)
8+
- installs the ssh key file.
9+
10+
Two other playbooks are subsets of this one: pbench-repo-install.yml
11+
performs the first step only; pbench-agent-config.yml performs the
12+
last two steps only.
13+
14+
N.B. Installation is incomplete until we install a key file so that
15+
=pbench=-move/copy-results= can move/copy results to the server and a
16+
config file so that it knows which server to use.
17+
18+
The playbooks use variables defined in the inventory file (for an
19+
example inventory file, see =Inventory/pbench-agent.hosts.example=).
20+
It must be modified for a given environment: see comments in the
21+
file for guidance.
1222

1323
* Usage
1424
#+begin_src shell
15-
ansible-playbook -i Inventory/pbench-agent.hosts pbench-agent-config.yml
25+
ansible-playbook -i /path/to/inventory/pbench-agent.hosts pbench-agent-install.yml
1626
#+end_src
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
2-
- name: install pbench.repo
2+
- name: install pbench-agent config and key files
33
hosts: servers
44
remote_user: root
55
become: yes
66
become_user: root
77

88
roles:
9-
- pbench-agent-install-key
10-
- pbench-agent-install-config
9+
- pbench-agent-config-install
10+
- pbench-agent-key-install
11+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- name: install pbench-agent
3+
hosts: servers
4+
remote_user: root
5+
become: yes
6+
become_user: root
7+
8+
roles:
9+
- pbench-repo-install
10+
- pbench-agent-install
11+
- pbench-agent-config-install
12+
- pbench-agent-key-install
13+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: install pbench-agent repo
3+
hosts: servers
4+
remote_user: root
5+
become: yes
6+
become_user: root
7+
8+
roles:
9+
- pbench-repo-install
10+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
pbench_agent_install_dir: /opt/pbench-agent
3+
pbench_agent_config_dest: "{{ pbench_agent_install_dir }}/config"
4+
pbench_owner: pbench
5+
pbench_group: pbench
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# Install config file for pbench agent.
3+
4+
- name: create temp dir to store the config locally
5+
delegate_to: localhost
6+
tempfile:
7+
state: directory
8+
prefix: "{{ inventory_hostname }}-"
9+
register: tempdir_1
10+
11+
- name: relax perms
12+
delegate_to: localhost
13+
file:
14+
path: "{{ tempdir_1.path }}"
15+
mode: 0755
16+
17+
- name: install the config file(s) locally
18+
delegate_to: localhost
19+
get_url:
20+
url: "{{ pbench_config_url }}/{{ item }}"
21+
dest: "{{ tempdir_1.path }}/{{ item }}"
22+
with_items: "{{ pbench_config_files }}"
23+
24+
- name: copy the config file(s) to the remote
25+
copy:
26+
src: "{{ tempdir_1.path }}/{{ item }}"
27+
dest: "{{ pbench_config_dest }}"
28+
mode: 0644
29+
owner: root
30+
group: root
31+
with_items: "{{ pbench_config_files }}"
32+
33+
- name: delete local temp dir
34+
delegate_to: localhost
35+
file:
36+
state: absent
37+
path: "{{ tempdir_1.path }}"

agent/ansible/roles/pbench-agent-install-config/tasks/main.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

agent/ansible/roles/pbench-agent-install-key/tasks/main.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)