Skip to content

Commit caf2a3e

Browse files
committed
Refactor real-afs into a common afs role and a real-specific role
1 parent 250b64e commit caf2a3e

File tree

9 files changed

+91
-73
lines changed

9 files changed

+91
-73
lines changed

ansible/roles/afs/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
afs_packages:
2+
- openafs-client
3+
afs_cache_size: 1000000
4+
afs_config_directory: '{{ "/usr/vice/etc" if ansible_os_family == "RedHat" else "/etc/openafs" }}'

ansible/roles/afs/handlers/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: restart openafs-client
3+
service:
4+
name: openafs-client
5+
enabled: yes
6+
state: restarted
7+
when: not openafs_started.changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: Install OpenAFS
3+
apt:
4+
name: "{{ afs_packages }}"
5+
- debconf: name=openafs-client question=openafs-client/thiscell vtype=string value=athena.mit.edu
6+
- debconf: name=openafs-client question=openafs-client/cachesize vtype=string value={{ afs_cache_size }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- name: Install OpenAFS
2+
dnf:
3+
name: "{{ afs_packages }}"
4+
state: present
5+
- name: Increase AFS performance
6+
ini_file:
7+
no_extra_spaces: yes
8+
path: /etc/sysconfig/openafs
9+
section: null
10+
option: AFSD_ARGS
11+
value: '"-afsdb -dynroot -fakestat -stat 25000 -daemons 100 -volumes 4000 -files {{ afs_cache_size // 25 }} -chunksize 19"'
12+
notify: restart openafs-client
13+
- name: Configure ThisCell
14+
copy:
15+
dest: "{{ afs_config_directory }}/ThisCell"
16+
content: |
17+
athena.mit.edu
18+
notify: restart openafs-client
19+
- name: Resize AFS cache
20+
copy:
21+
dest: "{{ afs_config_directory }}/cacheinfo"
22+
content: |
23+
/afs:/usr/vice/cache:{{ afs_cache_size }}
24+
notify: restart openafs-client

ansible/roles/afs/tasks/main.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
- include_tasks: 'install_{{ ansible_os_family }}.yml'
3+
- name: Configure CellServDB
4+
copy:
5+
dest: "{{ afs_config_directory }}/{{ afs_cellservdb_name }}"
6+
src: CellServDB.local
7+
notify: restart openafs-client
8+
- name: Configure CellAlias
9+
copy:
10+
dest: "{{ afs_config_directory }}/CellAlias"
11+
content: |
12+
athena.mit.edu athena
13+
csail.mit.edu csail
14+
dev.mit.edu dev
15+
lees.mit.edu lees
16+
net.mit.edu net
17+
ops.mit.edu ops
18+
sipb.mit.edu sipb
19+
andrew.cmu.edu andrew
20+
acpub.duke.edu acpub
21+
notify: restart openafs-client
22+
- name: Configure SuidCells
23+
copy:
24+
dest: "{{ afs_config_directory }}/{{ item }}"
25+
content: ""
26+
loop:
27+
- SuidCells
28+
- SuidCells.dist
29+
- SuidCells.local
30+
notify: restart openafs-client
31+
- name: Start openafs-client
32+
service:
33+
name: openafs-client
34+
enabled: yes
35+
state: started
36+
register: openafs_started

ansible/roles/real-afs/handlers/main.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
---
2-
- name: restart openafs-client
3-
service:
4-
name: openafs-client
5-
enabled: yes
6-
state: restarted
7-
notify: restart better-mousetrapfs
8-
when: not openafs_started.changed
92
- name: restart better-mousetrapfs
3+
listen: restart openafs-client
104
systemd:
115
daemon_reload: yes
126
name: afs-000.mount

ansible/roles/real-afs/meta/main.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,16 @@ dependencies:
44
- sysctl
55
- real-fuse
66
- real-keytabs
7+
- role: afs
8+
when: use_afs
9+
vars:
10+
afs_packages:
11+
- fuse-better-mousetrapfs
12+
- scripts-dkms-openafs
13+
- kernel-devel
14+
- scripts-openafs-client
15+
- scripts-openafs-authlibs
16+
- scripts-openafs-devel
17+
- scripts-openafs-krb5
18+
- tokensys
19+
afs_cellservdb_name: CellServDB.local

ansible/roles/real-afs/tasks/main.yml

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,12 @@
22
- name: Scripts AFS
33
when: use_afs
44
block:
5-
- name: Install OpenAFS
6-
dnf:
7-
name:
8-
- fuse-better-mousetrapfs
9-
- scripts-dkms-openafs
10-
- kernel-devel
11-
- scripts-openafs-client
12-
- scripts-openafs-authlibs
13-
- scripts-openafs-devel
14-
- scripts-openafs-krb5
15-
- tokensys
16-
state: present
175
- name: Disable garbage collection of PAGs
186
copy:
197
dest: /etc/sysctl.d/99-scripts-afs.conf
208
content: |
219
afs.GCPAGs = 0
2210
notify: apply sysctl
23-
- name: Increase AFS performance
24-
ini_file:
25-
no_extra_spaces: yes
26-
path: /etc/sysconfig/openafs
27-
section: null
28-
option: AFSD_ARGS
29-
value: '"-afsdb -dynroot -fakestat -stat 25000 -daemons 100 -volumes 4000 -files {{ afs_cache_size // 25 }} -chunksize 19"'
30-
notify: restart openafs-client
31-
- name: Configure ThisCell
32-
copy:
33-
dest: /usr/vice/etc/ThisCell
34-
content: |
35-
athena.mit.edu
36-
notify: restart openafs-client
37-
- name: Configure CellServDB
38-
copy:
39-
dest: /usr/vice/etc/CellServDB.local
40-
src: CellServDB.local
41-
notify: restart openafs-client
42-
- name: Configure CellAlias
43-
copy:
44-
dest: /usr/vice/etc/CellAlias
45-
content: |
46-
athena.mit.edu athena
47-
csail.mit.edu csail
48-
dev.mit.edu dev
49-
lees.mit.edu lees
50-
net.mit.edu net
51-
ops.mit.edu ops
52-
sipb.mit.edu sipb
53-
andrew.cmu.edu andrew
54-
acpub.duke.edu acpub
55-
notify: restart openafs-client
56-
- name: Resize AFS cache
57-
copy:
58-
dest: /usr/vice/etc/cacheinfo
59-
content: |
60-
/afs:/usr/vice/cache:{{ afs_cache_size }}
61-
notify: restart openafs-client
62-
- name: Configure SuidCells
63-
copy:
64-
dest: /usr/vice/etc/{{ item }}
65-
content: ""
66-
loop:
67-
- SuidCells
68-
- SuidCells.dist
69-
- SuidCells.local
70-
notify: restart openafs-client
7111
- name: Configure NetRestrict
7212
template:
7313
dest: /usr/vice/etc/NetRestrict
@@ -99,12 +39,6 @@
9939
notify:
10040
- restart openafs-client
10141
- restart better-mousetrapfs
102-
- name: Start openafs-client
103-
service:
104-
name: openafs-client
105-
enabled: yes
106-
state: started
107-
register: openafs_started
10842
- name: Start better-mousetrapfs
10943
systemd:
11044
daemon_reload: "{{ afs000_mount.changed }}"

0 commit comments

Comments
 (0)