-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspack-setup.yaml
More file actions
178 lines (160 loc) · 4.17 KB
/
spack-setup.yaml
File metadata and controls
178 lines (160 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
---
- name: 'Setup shared spack directory'
hosts: 'all'
vars:
spack_user: 'spack'
spack_group: 'users'
spack_root: '/opt/spack'
spack_url: 'https://github.com/spack/spack.git'
spack_repo_local: '/var/spack/repos/corelab'
spack_mirror_local: '/var/spack/mirror'
tasks:
- name: 'Create the spack user'
become: true
user:
name: '{{ spack_user }}'
group: '{{ spack_group }}'
system: yes
password: '!'
# Create a shared git repository with `git init --shared` as
# explained at https://stackoverflow.com/a/3167446
- name: 'Create spack directory'
become: yes
file:
state: 'directory'
path: '{{ spack_root }}'
owner: '{{ spack_user }}'
group: '{{ spack_group }}'
mode: 'g+ws'
- name: 'Initialize spack repo'
become: yes
become_user: '{{ spack_user }}'
command: 'git init --shared=group {{ spack_root }}'
args:
creates: '{{ spack_root }}/.git'
- name: 'Check spack origin'
command: 'git remote -v'
args:
chdir: '{{ spack_root }}'
register: remote
changed_when: no
- name: 'Set spack origin'
become: yes
become_user: '{{ spack_user }}'
command: 'git remote add origin {{ spack_url }}'
args:
chdir: '{{ spack_root }}'
when: remote.stdout_lines | length == 0
- name: 'Update spack repo'
become: yes
become_user: '{{ spack_user }}'
git:
repo: '{{ spack_url }}'
dest: '{{ spack_root }}'
- name: 'Add group write ownerships'
become: yes
file:
name: '{{ spack_root }}/{{ path }}'
mode: 'g+ws'
loop_control:
loop_var: 'path'
loop:
- 'var/spack'
- 'share/spack'
- 'opt/spack'
tags: 'chown'
- name: 'Load spack on login'
become: yes
copy:
content: |
source {{ spack_root }}/share/spack/setup-env.sh
dest: '/etc/profile.d/spack.sh'
- name: 'Create local spack repo and mirror'
become: yes
file:
state: 'directory'
path: '{{ path }}'
owner: '{{ spack_user }}'
group: '{{ spack_group }}'
mode: 'g+ws'
loop_control:
loop_var: 'path'
loop:
- '{{ spack_repo_local }}'
- '{{ spack_mirror_local }}'
tags:
- 'repo'
- 'mirror'
- name: 'Create spack settings directory'
become: yes
file:
state: 'directory'
path: '/etc/spack'
tags:
- 'repo'
- 'mirror'
- name: 'Set local spack repo to higher priority'
become: yes
copy:
content: |
repos:
- {{ spack_repo_local }}
- $spack/var/spack/repos/builtin
dest: '/etc/spack/repos.yaml'
tags: 'repo'
- name: 'Enable local spack mirror'
become: yes
copy:
content: |
mirrors:
local: file://{{ spack_mirror_local }}
dest: '/etc/spack/mirrors.yaml'
tags: 'mirror'
- name: 'Install dependencies'
become: yes
apt:
name:
- 'lmod'
- 'curl'
tags: 'deps'
# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=891541
- name: 'Find files affected by Debian bug 891541'
find:
paths: '/usr/lib/x86_64-linux-gnu/lua'
recurse: yes
pattern: 'posix_c.so'
file_type: 'link'
register: posix
tags: 'bugfix'
- name: 'Create symlinks for Debian bug 891541'
become: yes
file:
state: 'link'
src: '{{ path }}'
dest: '{{ path | regex_replace("_c.so$", ".so") }}'
loop_control:
loop_var: 'path'
loop: '{{ posix.files | map(attribute="path") | list }}'
tags: 'bugfix'
- name: 'Add cron job to update spack repo'
become: yes
cron:
user: '{{ spack_user }}'
cron_file: 'spack'
name: 'update spack repo'
hour: '0'
minute: '0'
job: '/usr/bin/git -C {{ spack_root }} pull'
tags: 'cron'
# UConn's Active Directory settings disable chmod g+s group
# directory ownership inheritance.
- name: 'Add cron job to fix spack permissions'
become: yes
cron:
user: '{{ spack_user }}'
cron_file: 'spack'
name: 'update spack repo'
hour: '0'
minute: '5'
job: '/bin/chown -R g+s {{ spack_root }}/var/spack/cache/_source-cache/archive/'
tags: 'cron'