-
-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathcreate-webhost.yml
More file actions
82 lines (75 loc) · 2.35 KB
/
create-webhost.yml
File metadata and controls
82 lines (75 loc) · 2.35 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
---
#
# sets up the host that runs nodejs.org, iojs.org and dist.libuv.org
#
# note: you have to account for a lot of storage in /home - it is
# currently using block storage from digitalocean which you will
# have to set up manually and have mounted to /home
# before proceeding
- hosts: infra-digitalocean-ubuntu2204-x64-2
roles:
- bootstrap
- package-upgrade
- baselayout
- { role: nginx, sites: [ 'nodejs.org', 'iojs.org', 'dist.libuv.org' ] }
pre_tasks:
- name: check if secrets are properly set
fail:
failed_when: not {{ secret }}
loop_control:
loop_var: secret
with_items:
- cdn_api_key
- cdn_api_email
- cdn_api_iojs_id
- cdn_api_nodejs_id
- cloudfuse_user
- cloudfuse_key
tasks:
- name: add nodesource signing key
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
state: present
- name: add nodesource repo
apt_repository:
repo: "{{ repo }}"
state: present
update_cache: yes
loop_control:
loop_var: repo
with_items:
- deb https://deb.nodesource.com/node_22.x nodistro main
- deb-src https://deb.nodesource.com/node_22.x nodistro main
- name: install node.js
apt: name=nodejs state=present
- name: add users
user:
name: "{{ user.name }}"
shell: /bin/bash
append: yes
groups: "{{ user.extra_group if 'extra_group' in user else '' }}"
loop_control:
loop_var: user
with_items:
- { name: libuv }
- { name: nodejs }
- { name: staging }
- { name: dist, extra_group: staging }
- name: create folder structure
file:
path: "/home/{{ folder[0] }}/{{ folder[1] }}/{{ folder[2] }}"
state: directory
mode: 0755
owner: "{{ folder[0] }}"
group: "{{ folder[0] }}"
loop_control:
loop_var: folder
# old structure looks like this
when: not('{{ folder[0] }}' == 'dist' and '{{ folder[2] }}' == 'custom')
and not('{{ folder[0] }}' == 'staging' and
'{{ folder[2] }}' in ['test', 'docs', 'rc'])
with_nested:
- [ 'dist', 'staging' ]
- [ 'nodejs', 'iojs' ]
- [ 'custom', 'docs', 'next-nightly', 'nightly',
'rc', 'release', 'test' ]