Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
bf4ff8d
ansible: first stab at refactor
jbergstroem Aug 9, 2016
8db0e84
update readme
jbergstroem Aug 9, 2016
44fd6aa
readme: add todo
jbergstroem Aug 10, 2016
e611026
refactor variables and roles
jbergstroem Aug 12, 2016
79352ab
move readme to where it belongs
jbergstroem Aug 12, 2016
e98f838
create a playbook that bootstraps alpine34
jbergstroem Aug 13, 2016
feb1334
fix: rename slaves to workers
jbergstroem Aug 17, 2016
47aedc8
stuff
jbergstroem Aug 17, 2016
27a7481
add host_vars for secrets
jbergstroem Aug 17, 2016
67a1b79
typo
jbergstroem Aug 17, 2016
9315ed1
feature: expand on bootstrapping
jbergstroem Aug 17, 2016
d3a15de
fix: only run selinux check on fedora24
jbergstroem Aug 17, 2016
af872e0
Create stubs for init scripts
jbergstroem Aug 18, 2016
e518701
wip: attempt to pass proxycommand logic
jbergstroem Aug 22, 2016
ed0b225
fix: dry regex
jbergstroem Aug 22, 2016
f67e55f
fix: refactor ssh templating
jbergstroem Aug 23, 2016
9007447
fix: remove unused filter plugin dir
jbergstroem Aug 23, 2016
6e6d2eb
fix: remove testing alias
jbergstroem Aug 23, 2016
c435802
fix: minor refactoring and todos
jbergstroem Aug 25, 2016
43670f1
fix: avoid extra variables
jbergstroem Aug 25, 2016
3c6bac1
feature: windows hosts, full inventory list (!)
jbergstroem Aug 25, 2016
defdcfd
tab2spaces
jbergstroem Aug 25, 2016
7b19620
fix: pass key to proxycommand
jbergstroem Aug 30, 2016
159b011
new aix host
jbergstroem Aug 30, 2016
28c51f8
fix: should->must
jbergstroem Aug 30, 2016
7f2409a
labels vs groups who knows. also: xgene
jbergstroem Aug 31, 2016
16be129
fix: xgene naming
jbergstroem Aug 31, 2016
beaf866
fix: refresh inventory and readme/todo
jbergstroem Aug 31, 2016
8b672e1
fix - MUY IMPORTANTE: proper indenting in config
jbergstroem Aug 31, 2016
ca79626
feature: dictsort hosts
jbergstroem Aug 31, 2016
39adfc4
improve readme
jbergstroem Aug 31, 2016
7e640c7
feature: streamline init scripts
jbergstroem Aug 31, 2016
76bbd8b
fix: dry
jbergstroem Aug 31, 2016
823297b
fix: nit in logic for bootstrapping ubuntu
jbergstroem Aug 31, 2016
4d602b3
fix: remove py3 compat stuff
jbergstroem Aug 31, 2016
c6c433a
fix: reference os in boostrap template
jbergstroem Sep 4, 2016
bc42205
feature: add stubs for updating packages
jbergstroem Sep 6, 2016
19729bd
centos5: monit
jbergstroem Sep 6, 2016
58676c3
feature: fix package updates for multiple os'es
jbergstroem Sep 7, 2016
ca104be
fix: sort connection issues
jbergstroem Sep 7, 2016
f015ae8
fix: default to root for ssh
jbergstroem Sep 7, 2016
df97f6e
doc: note about upgrade-packages
jbergstroem Sep 7, 2016
f982b2e
doc: We actually require ansible 2.1.x now
jbergstroem Sep 7, 2016
3b97572
fix: improve readme
jbergstroem Sep 7, 2016
1bc963c
fix: nitpick README
jbergstroem Sep 7, 2016
eeb81b3
feature: dry the filter plug
jbergstroem Sep 7, 2016
748babd
fix: rename proper
jbergstroem Sep 7, 2016
60f0ab2
fix: remove old stuff
jbergstroem Sep 7, 2016
123b9d9
doc: nits
jbergstroem Sep 7, 2016
8472927
refactor: split worker/baselayout
jbergstroem Sep 7, 2016
a47aaa8
fix: improve documentation
jbergstroem Sep 12, 2016
0e597b6
feature: python path exceptions
jbergstroem Sep 12, 2016
281a848
fix: bugs in unwrapping metadata
jbergstroem Sep 12, 2016
367ef7f
fix: avoid subdirs in playbooks
jbergstroem Sep 12, 2016
be3451a
fix: `when` ordering
jbergstroem Sep 12, 2016
7ee0583
fix: remove unused file
jbergstroem Sep 12, 2016
0a5f581
fix: typo
jbergstroem Sep 12, 2016
f8631f2
fix: add additional providers
jbergstroem Sep 12, 2016
9817b12
feature: refactor package upgrades
jbergstroem Sep 12, 2016
16d2f3a
fix: add release host and order
jbergstroem Sep 12, 2016
546ca13
fix: typo for lineinfile
jbergstroem Sep 13, 2016
c1a40f9
feature: set default for match_key
jbergstroem Sep 13, 2016
04fd908
feature: add more operating system exceptions
jbergstroem Sep 14, 2016
1ea1b48
fix: ssh template didn't use proxycommand properly
jbergstroem Sep 15, 2016
fdb7189
fix: (finally) verify all connection types
jbergstroem Sep 18, 2016
63533bc
feature: add stubs for repos
jbergstroem Sep 21, 2016
8439d2b
feature: add a semi-working ccache poller
jbergstroem Sep 21, 2016
ff082b3
feature: add a playbook for replacing keys
jbergstroem Sep 21, 2016
c2a0c42
fix: add run_once to reading pubkey
jbergstroem Sep 21, 2016
3276a49
doc: elaborate on the `raw` rationale
jbergstroem Sep 21, 2016
45e5f21
doc: mention update-ssh-keys.yml
jbergstroem Sep 21, 2016
c2981a9
fix: typo! run_one -> run_once
jbergstroem Sep 21, 2016
207e47e
doc: minor nits
jbergstroem Sep 22, 2016
375ea9e
baselayout: add sudo
jbergstroem Sep 22, 2016
a8f938c
add two new rpi's
jbergstroem Sep 22, 2016
60e4f02
update-ssh-keys: pass new key by prompting path
jbergstroem Sep 22, 2016
7ff1962
doc: correct host definition
jbergstroem Sep 23, 2016
3325dbf
introduce a dynamic inventory plugin
jbergstroem Sep 27, 2016
3643f0f
doc: reorder host addition
jbergstroem Sep 27, 2016
2d58bfc
doc: no quirks, just config options
jbergstroem Sep 27, 2016
3ae0d96
doc: skip homebrew
jbergstroem Sep 27, 2016
12926ea
doc: remove unnecessary todos
jbergstroem Sep 27, 2016
8063c2b
doc: engrish
jbergstroem Sep 27, 2016
ccde8b2
pep8
jbergstroem Sep 28, 2016
9d683f2
baselayout: add missing reference
jbergstroem Sep 29, 2016
a358efa
fix: avoid quoting to fix escaping issues
jbergstroem Sep 29, 2016
9ab782b
ssh_config: properly reference ansible_user
jbergstroem Sep 29, 2016
fb1d6da
update_ssh_keys: refactor
jbergstroem Sep 29, 2016
e8c0b5a
inventory: skip windows hosts
jbergstroem Sep 29, 2016
1204bdc
doc: readme updates
jbergstroem Sep 29, 2016
c1dd632
feature: commit all the things
jbergstroem Sep 29, 2016
6484999
scattered work, v2
jbergstroem Sep 29, 2016
717d0b7
doc: add a note about requiring ansible 2.2.0
jbergstroem Sep 29, 2016
a7b3971
inventory: update ip's for ppcle/be hosts
jbergstroem Sep 29, 2016
9b96fe1
commit dump, v3
jbergstroem Oct 3, 2016
cebd26c
alpine34: full playbook
jbergstroem Oct 3, 2016
5d61a70
smartos: add playbook
jbergstroem Oct 3, 2016
2ec17c1
improve host_vars checker
jbergstroem Oct 3, 2016
74c8b37
doc: update todo
jbergstroem Oct 3, 2016
12b4df6
doc: update job info
jbergstroem Oct 3, 2016
f3a7226
smartos: add java args
jbergstroem Oct 4, 2016
9879959
roles: fix deprecation warnings
jbergstroem Oct 4, 2016
baaa324
freebsd: minor fixes
jbergstroem Oct 4, 2016
c4280f7
new playbooks: www, linter
jbergstroem Oct 4, 2016
3ea064f
doc: update todo
jbergstroem Oct 4, 2016
6dd8f8e
new playbook: update worker jars
jbergstroem Oct 4, 2016
04dfd2c
doc: rename www job to webhost
jbergstroem Oct 4, 2016
d01437f
avoid lint hosts when creating jenkins hosts
jbergstroem Oct 4, 2016
5a9cccf
inventory: remove redundant hosts
jbergstroem Oct 4, 2016
930935d
freebsd: add new host
jbergstroem Oct 4, 2016
dc0bd28
freebsd: pass user to init script
jbergstroem Oct 4, 2016
7f80b51
fix: avoid passing username to daemon
jbergstroem Oct 5, 2016
79efd79
fix: fix $name_env inconsistencies in freebsd
jbergstroem Oct 5, 2016
a66b1ef
freebsd: fix path to bash when creating user
jbergstroem Oct 5, 2016
66a0eed
recommission new www host on ubuntu1604
jbergstroem Oct 6, 2016
f3952d1
fix: args is required
jbergstroem Oct 6, 2016
afb82f5
webhost: work in progress
jbergstroem Oct 6, 2016
48243f4
mixed bag, friday edition
jbergstroem Oct 7, 2016
36137ac
fix: newline after 'starting' output
jbergstroem Oct 7, 2016
202245b
freebsd: improve init script, again
jbergstroem Oct 11, 2016
1ea9a79
freebsd: set HOME properly
jbergstroem Oct 11, 2016
8bf1290
alpine: add m4
jbergstroem Oct 15, 2016
f4e3256
alpine: add autoconf
jbergstroem Oct 15, 2016
c6b9764
update host list
jbergstroem Oct 27, 2016
c774b61
inventory: fully replace nodesource with requireio
jbergstroem Oct 28, 2016
e5e52c9
freebsd: support freebsd 11
jbergstroem Nov 11, 2016
ea1d858
inventory: update and introduce ubuntu1610
jbergstroem Nov 11, 2016
4466346
config: use a ini-like format
jbergstroem Nov 11, 2016
3489045
doc: add note about clang symlinks
jbergstroem Nov 11, 2016
8c6e0a5
boostrap: support ubuntu1610
jbergstroem Nov 11, 2016
8108e27
jenkins-worker: treat centos5 config as default
jbergstroem Nov 11, 2016
e397680
wip: install tap2junit
jbergstroem Nov 11, 2016
9c9cd30
nitpick: pass args
jbergstroem Nov 11, 2016
86f0e0e
baselayout: gather full subset
jbergstroem Nov 11, 2016
6bbe512
debian: specify java version
jbergstroem Nov 11, 2016
eac8747
too many things
jbergstroem Dec 28, 2016
f117dc5
fix: restart in systemd service
joaocgreis Dec 18, 2016
85c0dda
random things [see desc]
jbergstroem Jan 31, 2017
19a325d
add a note about hosts requiring more ram
jbergstroem Jan 31, 2017
8fa2a89
docs: more todo
jbergstroem Jan 31, 2017
eafa00a
New module for generating remmina file
piccoloaiutante Mar 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ansible/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true

[*.yml]
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions ansible/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
host_vars/*
!host_vars/README.md
168 changes: 168 additions & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Ansible scripts for the Node.js build group infrastructure

(in lack of a better title)


## Getting started

1. Install Ansible 2.2.0 or newer: `pip install ansible`. **Note**: if you're
using homebrew you'll have to manage dependencies such as `PyAML` yourself.
2. Read this document.
3. Clone the node secrets repository (if you don't have access ask anyone
in the [build group](https://github.com/nodejs/build#people).
4. Copy the private keys (check the secrets repo for instructions) to your
`~/.ssh` folder. Make sure they have the same name. What keys are available
to you depends on what role you have. In order to create new vm's and hook
them up to CI you have to be part of the `infra` group.


## Getting things done

Most of your work will probably include editing `inventory.yml`, followed by
running one (or multiple) of below playbooks. If you're adding a new host,
limiting ansible to just running on that host is probably quicker:

```console
$ ansible-playbook playbooks/create-jenkins-worker.yml \
--limit "test-digitalocean-debian8-x64-1"
```

..in fact, you most likely want to use `--limit` for everything when you just
need to edit a few set of hosts.

These playbooks are available to you:

- **jenkins/host/create.yml**: Sets up jenkins ci hosts.

- **jenkins/host/iptables.yml**: Update iptables rules so workers can connect.

- **jenkins/worker/create.yml**: Sets up jenkins workers.

- **jenkins/worker/upgrade-jar.yml**: Upgrades the worker jar file.

- **jenkins/linter.yml**: Sets up the code linters (flavour of a worker).

- **create-webhost.yml**: Configures the server(s) that host nodejs.org,
iojs.org and dist.libuv.org among other things.

- **create-unencrypted.yml**: Configures unencrypted.nodejs.org.

- **upgrade-packages.yml**: Upgrades packages on provided hosts.

- **update-ssh-keys.yml**: Updates (and verifies) {,pub}keys both locally
and remote. This is useful if you want to cycle keys.

- **write-ssh-config.yml**: Updates your ~/.ssh/config with hosts from
inventory.cfg if your ssh config contains these template stubs:
```console
# begin: node.js template

# end: node.js template
```

If something isn't working, you will likely get a warning or error.
Have a look at the playbooks or roles. They are well documented and should
(hopefully) be easy to improve.


## Adding a new host to inventory.yml

Hosts are listed as part of an yaml collection. Find the type and provider and
add your host in the list (alphabetical order). Your host can start with an
optional sponsor - for instance `rvagg-debian7-arm_pi1p-1` - which expands
into `test-nodesource_rvagg-debian7-arm_pi1p-1`.

Since we use yaml, we can abstract away `$type` and `$provider` by creating
subelements:

```yaml
- test:
- digitalocean:
- debian8-x64-1: {ip: 1.2.3.4}
```

Make sure you follow the naming convention. There are scripts in place that
will throw errors if you don't. Using an incorrect convention will likely
lead to unwanted consequences.

### Naming

Each host must follow this naming convention:

```yaml
$type-$provider(_$optionalmeta)-$os-$architecture(_$optionalmeta)-$uid
```

For more information refer to other hosts in `inventory.yml` or the
[ansible callback that is responsible for parsing it][callback].


### Metadata

Each host needs a bit of metadata:

- (required) `ip`: used both by ansible and placed in your ssh config.
- `user`: only provide if ssh requires a non-root login. Passing this
will additionally make ansible try to become root for all
commands executed.
- `alias`: creates shorthand names for ssh convenience.
- `labels`: Each host can also labels. More on that below.

### Adding extra options to a host

Hosts can inherit extra options by adding them to `ansible.cfg`. These are
freeform and are passed to ansible. One example is adding a proxycommand
configuration to hosts at NodeSource since they sit behind a jumphost.

Add a config section by creating a group with the name of the hosts you want
to match (matches on full hostname). Since this is passed to `host_vars` it
can be any kind of ansible variable/config:

```ini
[hosts:freebsd]
ansible_python_interpreter: /usr/local/bin/python
```

**Note**: We currently can't use ansible's built-in support for `proxy_command`
since that will enable the `paramiko` connection plugin, disregard
other ssh-specific options.



### TODO

Unsorted stuff of things we need to do/think about

- [ ] playbook: copy keys and config to release machines
- [ ] avoid messing with keys on machines that has multiple usage such as jump
hosts (or set up a new jump host)
- [ ] copy release (staging) keys to release machines
- [ ] backup host: generate config, install rsnapshot
- [ ] switch to slaveLog for all jenkins instances lacking stdout redirection
(note: this depends on init type!)
- [ ] add iptables-save-persistent to cron on ci hosts
- [ ] [unencrypted host](https://git.io/v6H1z)
- [ ] when creating additional jenkins labels based on `labels=` add os/arch
as part of hte label (ref: rvagg long irc talk see 2016-08-29 logs)
- [ ] follow up ansible upstream wrt hostname support for smartos/alpine
- [ ] callback plugin: make `nodejs_yaml` a class and support `--host`
- [ ] add label support to jenkins
- [ ] move all service-related stuff to handlers
- [ ] find a nicer way of adding proxyhosts to iptables
- [ ] add clang/clang++ symlinks for ccache
- [ ] centos7 needs different ccache path
- [ ] fedora 24 and 25 needs to either handle selinux or just disable it
- [ ] fedora 24 and 25: ccache lives in /usr/lib64/ccache
- [ ] debian7 needs to update alternative gcc/g++
- [ ] adding scl stuff on centos5/6 is broken
- [ ] verify that /usr/local/bin works as ccache install path
- [x] remove subversion since v8 tests uses git nowadays
- [ ] assign 192/256mb ram to the jenkins instances that requires it:
- aix
- TBD
- [ ] centos5 and 6 repositories for rhel* stuff is broken
- [ ] remove native alpine34 vm's on joyent since the joyent host
is not mature enough to provide linux emulation. use docker instead.

[callback]: plugins/inventory/nodejs_yaml.py

30 changes: 30 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[defaults]
filter_plugins = plugins/filter
gathering = explicit
host_key_checking = False
inventory = plugins/inventory/nodejs_yaml.py
library = plugins/library
remote_user = root
retry_files_enabled = False
roles_path = roles
squash_actions = apk

# Pass an empty path to ssh so it doesn't read config. We don't need it
# since we have all infomation available.
[ssh_connection]
ssh_args = -F /dev/null -o ControlMaster=auto -o ControlPersist=60s
scp_if_ssh = True

[privilege_escalation]
become_user = root
become_method = sudo

[hosts:requireio]
ansible_ssh_common_args = -o ProxyCommand='ssh -i {{ ansible_ssh_private_key_file }} -W %h:%p -p 2222 [email protected]'
become_method = sudo

[hosts:smartos]
ansible_python_interpreter = /opt/local/bin/python

[hosts:freebsd]
ansible_python_interpreter = /usr/local/bin/python
4 changes: 4 additions & 0 deletions ansible/group_vars/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jenkins_url: "https://ci-release.nodejs.org"
# intentionally fetching `slave.jar` from ci.nodejs.org to avoid auth problems
jenkins_worker_jar: "https://ci.nodejs.org/jnlpJars/slave.jar"
server_user: "iojs"
3 changes: 3 additions & 0 deletions ansible/group_vars/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
jenkins_url: "https://ci.nodejs.org"
jenkins_worker_jar: "{{ jenkins_url }}/jnlpJars/slave.jar"
server_user: iojs
21 changes: 21 additions & 0 deletions ansible/host_vars/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## The `host_vars` folder

If you have to handle secrets for workers or pass other variables,
create a file in here with the same name as the machine and store it
in there. It will be automatically made available as part of the
ansible playbook.

### Variables

You will always have to set the following variables to configure a host:

- `secret`: the jenkins slave secrets

#### Optional variables

Variables that _might_ be available for you to change depending on
what init system your host will be running:

- `server_jobs`: the number of parallel jobs to run on a host
- `server_ram`: how much memory the slave should assign to java-base
(defaults to "128m")
Loading