Skip to content

Commit 81d1904

Browse files
authored
Merge pull request #28 from pescobar/inventory_folder
added inventory/ folder
2 parents d8d2714 + 9ead9d4 commit 81d1904

17 files changed

+119
-81
lines changed

README.md

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,45 +37,61 @@ ansible-galaxy role install -r requirements.yml -p ./roles
3737

3838
### Configuration
3939

40-
The EESSI specific settings can be found in `group_vars/all.yml`, and in `templates` we added our own templates
40+
The EESSI specific settings can be found in `inventory/group_vars/all.yml`, and in `templates` we added our own templates
4141
of Squid configurations for the Stratum 1 and local proxy servers.
42-
For all playbooks you will also need to have an appropriate Ansible `hosts` file;
43-
see the supplied `hosts.example` for the structure and host groups that you need for these playbooks.
42+
For all playbooks you will also need to have an appropriate Ansible `hosts` file in the `inventory` folder;
43+
see the supplied `inventory/hosts.example` for the structure and host groups that you need for these playbooks.
44+
45+
Ansible offers several ways to override any configuration parameters. Of course you can edit a playbook or the `all.yml` file,
46+
but it is best to keep these files unmodified.
47+
48+
#### Machine-specific configuration
49+
If the setting is for one specific machine (e.g. your Stratum 1 machine), it is recommended to make a file in the `inventory/host_vars` directory and use the machine name as name of the file.
50+
This file can contain any settings that should be overridden for this particular machine. See `stratum0host.example` in that directory for an example.
51+
Any other files that you will create in this directory will be ignored by git.
52+
53+
54+
#### Site-specific configuration
55+
Any other site-specific configuration items can go into a file `inventory/local_site_specific_vars.yml` (which will be ignored by git).
56+
We provided an example file that shows the kind of configuration that you should minimally provide.
57+
You can also add more items that you would like to override to this file. See the next section for instructions about passing
58+
your configuration file to the playbook.
59+
4460

4561
## Running the playbooks
4662

4763
In general, all the playbooks can be run like this:
4864
```
49-
ansible-playbook -i hosts -b <name of playbook>.yml
65+
ansible-playbook -b -e @inventory/local_site_specific_vars.yml <name of playbook>.yml
5066
```
51-
where `-i` allows you to specify the path to your hosts file, and `-b` means "become", i.e. run with `sudo`.
67+
Here the option `-e @/path/to/your/config.yml` is used to include your site-specific configuration file.
68+
The `-b` option means "become", i.e. run with `sudo`.
5269
If this requires a password, include `-K`, which will ask for the `sudo` password when running the playbook:
5370
```
54-
ansible-playbook -i hosts -b -K <name of playbook>.yml
71+
ansible-playbook -b -K -e @inventory/local_site_specific_vars.yml <name of playbook>.yml
5572
```
5673

57-
Before you run any of the commands below, make sure that you updated the file `group_vars/all.yml`
58-
and include the new/extra URLs of any server you want to change/add (e.g. add your Stratum 1).
74+
Before you run any of the commands below, make sure that you created a `inventory/hosts` file, a site-specific configuration file,
75+
and, if necessary, created machine-specific configuration files in `inventory/host_vars`.
5976

6077
### Firewalls
6178
To make all communication between the CVMFS services possible, some ports have to be opened on the Stratum 0 (default: port 80),
6279
Stratum 1 (default: port 80 and 8000), and local proxy (default: port 3128).
63-
These default port numbers are listed in `roles/cvmfs/defaults/main.yml`, but can be overridden elsewhere.
80+
These default port numbers are listed in `roles/galaxyproject.cvmfs/defaults/main.yml`, but can be overridden in your local
81+
configuration file (`local_site_specific_vars.yml`).
6482

6583
The Ansible playbook can update your firewall rules automatically (`firewalld` on Redhat systems, `ufw` on Debian systems),
6684
but by default it will not do this. If you want to enable this functionality, set `cvmfs_manage_firewall` to `true`.
67-
This can be done in either `group_vars/all.yml`, or in a vars section in your hosts or playbook file, or by passing
68-
`-e cvmfs_manage_firewall=true` to the `ansible-playbook` command.
6985

7086
### Stratum 0
7187
First install the Stratum 0 server:
7288
```
73-
ansible-playbook -i hosts -b -K stratum0.yml
89+
ansible-playbook -b -K -e @inventory/local_site_specific_vars.yml stratum0.yml
7490
```
7591

7692
Then install the files for the configuration repository:
7793
```
78-
ansible-playbook -i hosts -b -K stratum0-deploy-cvmfs-config.yml
94+
ansible-playbook -b -K -e @inventory/local_site_specific_vars.yml stratum0-deploy-cvmfs-config.yml
7995
```
8096

8197
Note that there can be only one Stratum 0, so you should only run this playbook
@@ -87,55 +103,47 @@ the (geographically) closest Stratum 1 server for your client and proxies.
87103
More information on how to (freely) obtain this key is available in the CVMFS documentation:
88104
https://cvmfs.readthedocs.io/en/stable/cpt-replica.html#geo-api-setup .
89105

90-
You can put your license key in `group_vars/all.yml`, or add a section in your `hosts` file:
91-
```yaml
92-
[cvmfsstratum1servers:vars]
93-
cvmfs_geo_license_key=XXXXX
94-
```
106+
You can put your license key in the local configuration file `inventory/local_site_specific_vars.yml`.
95107

96108
Furthermore, the Stratum 1 runs a Squid server. The template configuration file can be found at
97109
`templates/eessi_stratum1_squid.conf.j2`.
98110
If you want to customize it, for instance for limiting the access to the Stratum 1,
99-
you can make your own version of this template file and point to it by editing the playbook or
100-
adding the following to `group_vars/all.yml` or the section in your `hosts` file:
101-
```yaml
102-
cvmfs_squid_conf_src=/path/to/your_stratum1_squid.conf.j2
103-
```
111+
you can make your own version of this template file and point to it by overriding the following setting in `inventory/local_site_specific_vars.yml`.
112+
See the comments in the example file for more details.
113+
104114
Install the Stratum 1 using:
105115
```
106-
ansible-playbook -i hosts -b -K stratum1.yml
116+
ansible-playbook -b -K -e @inventory/local_site_specific_vars.yml stratum1.yml
107117
```
108118
This will automatically make replicas of all the repositories defined in `group_vars/all.yml`.
109119

110120
### Local proxies
111121
The local proxies also need a Squid configuration file; the default can be found in
112122
`templates/localproxy_squid.conf.j2`.
123+
If you want to customize the Squid configuration more, you can also make your own file, and point to in `inventory/local_site_specific_vars.yml`.
124+
See the comments in the example file for more details.
113125

114-
You have to define the lists of IP addresses / ranges (using CIDR notation) that are allowed to use the proxy using the variable `cvmfs_localproxy_allowed_clients`.
115-
You can put this, for instance, in your hosts file. See `hosts.example` for more details.
116-
117-
If you want to customize the Squid configuration more, you can also make your own file, and point to it using `cvmfs_squid_conf_src` (see the Stratum 1 section).
126+
Furthermore, you have to define the lists of IP addresses / ranges (using CIDR notation) that are allowed to use the proxy using the variable `local_cvmfs_http_proxies_allowed_clients`.
127+
Again, see `inventory/local_site_specific_vars.yml.example` for more details.
118128

119129
Do keep in mind that you should never accept proxy request from everywhere to everywhere!
120130
Besides having a Squid configuration with the right ACLs, it is recommended to also have a firewall that limits access to your proxy.
121131

122132
Deploy your proxies using:
123133
```
124-
ansible-playbook -i hosts -b -K localproxy.yml
134+
ansible-playbook -b -K -e @inventory/local_site_specific_vars.yml localproxy.yml
125135
```
126136

127137
### Clients
128138
Make sure that your hosts file contains the list of hosts where the CVMFS client should be installed.
129-
Furthermore, you can add a vars section for the clients that contains the list of (local) proxy servers
130-
that your clients should use:
131-
```yaml
132-
[cvmfsclients:vars]
133-
cvmfs_http_proxies=["your-local.proxy:3128"]
134-
```
139+
Furthermore, you can define a list of (local) proxy servers
140+
that your clients should use in `inventory/local_site_specific_vars.yml` using the parameter `local_cvmfs_http_proxies`.
141+
See `inventory/local_site_specific_vars.yml.example` for more details.
135142
If you just want to roll out one client without a proxy, you can leave this out.
143+
136144
Finally, run the playbook:
137145
```
138-
ansible-playbook -i hosts -b -K client.yml
146+
ansible-playbook -b -K -e @inventory/local_site_specific_vars.yml client.yml
139147
```
140148

141149
## Verification and usage

ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
inventory = ./inventory/hosts

client.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
---
33
- name: CVMFS clients
44
hosts: cvmfsclients
5-
vars:
6-
eessi_cvmfs_repos_enabled: config-repo
75
roles:
86
- galaxyproject.cvmfs

hosts.example

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

inventory/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local_site_specific_vars.yml
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
---
22
# vars file for eessi project
33

4-
# The license key for the Geo API:
5-
# https://cvmfs.readthedocs.io/en/stable/cpt-replica.html#geo-api-setup
6-
# For some unclear reason, the Stratum 1 installation fails when this is not set:
7-
# https://github.com/EESSI/filesystem-layer/issues/2
8-
#cvmfs_geo_license_key:
9-
104
# Automatically configure EESSI CVMFS repos.
115
eessi_cvmfs_repos_enabled: config-repo
126

inventory/group_vars/cvmfsclients

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
3+
# List of proxies to be used for the clients.
4+
# Override this setting in your local_site_specific_vars.yml file.
5+
cvmfs_http_proxies: "{{ local_cvmfs_http_proxies }}"
6+
7+
# Use the CVMFS configuration repository for the clients.
8+
eessi_cvmfs_repos_enabled: config-repo
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
cvmfs_squid_conf_src: "{{ local_proxies_cvmfs_squid_conf_src | default('eessi_localproxy_squid.conf.j2') }}"
4+
5+
# List of clients allowed to access your proxies.
6+
# Override this setting in local_site_specific_vars.yml.
7+
cvmfs_localproxy_allowed_clients: "{{ local_cvmfs_http_proxies_allowed_clients }}"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
cvmfs_repositories: "{{ eessi_cvmfs_repositories + [eessi_cvmfs_config_repo.repository] }}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
cvmfs_repositories: "{{ eessi_cvmfs_repositories + [eessi_cvmfs_config_repo.repository] }}"
4+
cvmfs_keys: "{{ eessi_cvmfs_keys + [eessi_cvmfs_config_repo.key] }}"
5+
cvmfs_squid_conf_src: "{{ local_stratum1_cvmfs_squid_conf_src | default('eessi_stratum1_squid.conf.j2') }}"

0 commit comments

Comments
 (0)