Skip to content

Commit

Permalink
CI GH Actions structure (#112)
Browse files Browse the repository at this point in the history
* Update to Nomad 0.11.3 (#96)

Addresses #84

* Fix booleans in template (#94)

nomad expects booleans in lower-case. this fixes several variables

* Update nomad to 0.12.0 (#98)

Update to nomad 0.12.0 #97

* Update nomad to v0.12.1 (#104)

Addresses #103

* Improve Vault Support for Namespace, Tokens (#102)

This adds support for Vault namespaces (from Vault Enterprise).
Additionally, this ensures that a vault token is not installed on client
nodes. Per the nomad documentation, this token only needs be installed
on servers, and tokens will be delegated appropriately to client nodes.

Addresses #101

* add parameter deployment_gc_threshold (#99)

Co-authored-by: beechesII <christopher.grau@t-systems.com>

* Feature/nomad autopilot (#100)

* add configuration for Nomad autopilot Stanza

* correct variable names

Co-authored-by: beechesII <christopher.grau@t-systems.com>

* Reference requirement for unzip

In response to #89 ...  unzip is a dependency of ansible unarchive module.

* fix cgroup-bin transition package for newer distro releases (#108)

* Fix After and Wants to start after networking (#110)

According to https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ this is the correct way to start a service only after the network has come all the way up.
According to https://www.freedesktop.org/software/systemd/man/systemd.special.html#basic.target "systemd automatically adds dependency of the type After= for this target unit to all services (except for those with DefaultDependencies=no)", therefore having it here is redundant.

* Added configuation for podman and general plugin setups. (#111)

* Added configuation for podman and general plugin setups.

* Added storage usiing the same macro.

* Removed the new hosts storage since the function existed already.

* Corrected installation order.

* CI test

* CI test

* fix action

* fix action

* CI test

* CI bug wa

* CI bug wa

* File permissions

* File permissions

* Add centos7

* File permissions

* Fix syntax

* Use sh

* Disable idempotence molecule test

* Cleaning

* fix lint

* Fix tests

* cleanup in lists of systems

* Comment all except Ubuntu-18

* Fix tests

* Add Ubuntu-20

* Set ansible-lint warnings

* Set ansible-lint warnings

* Set ansible-lint exceptions

* Temp. disable lint

* Edit scenario

* Try different image

* Edit scenario

* add molecule github actions

* add molecle tasks

* add lint forgiveness

* lint tweaks

* fix ansible lint

* remove custom yaml lint

* copied yamllint config from consul rolee

* remove document start linting

* test remove idempotence test

* comment spacing

* exclude 301, ansible lint

* use new lint syntax

* rollback base

* just 1 scenario while debugging

* fixes fro yamllint

* CI test

* CI test

* fix action

* fix action

* CI test

* CI bug wa

* CI bug wa

* File permissions

* File permissions

* Add centos7

* File permissions

* Fix syntax

* Use sh

* Disable idempotence molecule test

* Cleaning

* fix lint

* Fix tests

* cleanup in lists of systems

* Comment all except Ubuntu-18

* Fix tests

* Add Ubuntu-20

* Set ansible-lint warnings

* Set ansible-lint warnings

* Set ansible-lint exceptions

* Temp. disable lint

* Edit scenario

* Try different image

* Edit scenario

* Edit scenario

* CI test

* Clean the mess

* Clean the mess

* Rmove temporary CI rule

* CI test

* Rmove temporary CI rule

Co-authored-by: adawalli <adam.wallis@gmail.com>
Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
Co-authored-by: Christopher Grau <66788631+beechesII@users.noreply.github.com>
Co-authored-by: beechesII <christopher.grau@t-systems.com>
Co-authored-by: lanefu <lanefu@users.noreply.github.com>
Co-authored-by: John Adams <john@hexb.it>
Co-authored-by: jebas <jeff.l.baskin@gmail.com>
Co-authored-by: Michal Muransky <michal.muransky@pan-net.eu>
Co-authored-by: Lane Jennison <lane@lane-fu.com>
Co-authored-by: Bas Meijer <bas.meijer@me.com>
  • Loading branch information
11 people authored Nov 7, 2020
1 parent 47f1c89 commit 0a627fb
Show file tree
Hide file tree
Showing 35 changed files with 367 additions and 132 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip_list:
- '106'
28 changes: 14 additions & 14 deletions .github/workflows/molecule.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 4
matrix:
scenario:
# - centos-6
# - centos-7
# - centos-8
# - debian-8
# - debian-9
# - debian-10
# - fedora-26
# - fedora-27
# - fedora-28
# - fedora-29
# - fedora-30
# - fedora-31
# - oraclelinux-6
# - centos-6 ## Nomad requires Glibc 2.14
- centos-7
- centos-8
# - debian-8 ## OS packages TASK failing
# - debian-9 ## Debian 9 is failing the verify script when checking if service is enabled
- debian-10
- fedora-30
- fedora-31
- fedora-32
- fedora-33
# - oraclelinux-6 ## OracleLinux is not supported by the Role yet
# - oraclelinux-7
# - oraclelinux-8
# - ubuntu-16.04
# - ubuntu-16.04 ## OS packages TASK failing
- ubuntu-18.04
# - ubuntu-20.04 ## Same as Debian 9 - failing the verify script when checking if service is enabled

steps:
- uses: actions/checkout@v2
Expand Down
75 changes: 69 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

----

This role was previously maintained by Brian Shumate and is now curated by [@ansible-community/hashicorp-tools](https://github.com/ansible-community).
This role was previously maintained by Brian Shumate and is now curated by [@ansible-community/hashicorp-tools](https://github.com/ansible-community).

----

Expand All @@ -21,12 +21,13 @@ This role requires an Arch Linux, Debian, RHEL, or Ubuntu distribution; the role
with the following specific software versions:

* Ansible: 2.7.10
* nomad: 0.10.3
* nomad: 0.12.1
* Arch Linux
* CentOS: 7
* Debian: 8
* RHEL: 7
* Ubuntu: 16.04
* unzip for [unarchive module](https://docs.ansible.com/ansible/latest/modules/unarchive_module.html#notes)

## Role Variables

Expand All @@ -39,7 +40,7 @@ The role defines most of its variables in `defaults/main.yml`:
### `nomad_version`

- Nomad version to install
- Default value: **0.10.3**
- Default value: **0.12.0**

### `nomad_architecture_map`

Expand Down Expand Up @@ -208,11 +209,21 @@ The role defines most of its variables in `defaults/main.yml`:
- Eval garbage collection threshold
- Default value: **1h**

### `nomad_deployment_gc_threshold`

- Deployment garbage collection threshold
- Default value: **1h**

### `nomad_encrypt`

- Encryption secret for gossip communication
- Default value: **""**

### `nomad_raft_protocol`

- Specifies the version of raft protocal, which used by nomad servers for communication
- Default value: **2**

### `nomad_authoritative_region`

- Specifies the authoritative region, which provides a single source of truth for global configurations such as ACL Policies and global ACL tokens.
Expand Down Expand Up @@ -336,12 +347,12 @@ nomad_host_volumes:
### `nomad_bind_address`

- Bind interface address
- Default value: `{{ hostvars[inventory_hostname]['ansible_'+ nomad_iface ]['ipv4']['address'] }}`
- Default value: `{{ hostvars[inventory_hostname]['ansible_'+ nomad_iface ]['ipv4']['address'] }}`

### `nomad_advertise_address`

- Network interface address to advertise to other nodes
- Default value: `{{ hostvars[inventory_hostname]['ansible_'+ nomad_iface ]['ipv4']['address'] }}`
- Default value: `{{ hostvars[inventory_hostname]['ansible_'+ nomad_iface ]['ipv4']['address'] }}`

### `nomad_ports`

Expand All @@ -363,11 +374,32 @@ nomad_host_volumes:
- Serf port
- Default value: **4648**

### `nomad_podman_enable`

- Installs the podman plugin
- Default value: **false**

### `nomad_docker_enable`

- Install Docker subsystem on nodes?
- Default value: **false**

### `nomad_plugins`
- Allow you configure nomad plugins.
- Default: {}

Example:

```yaml
nomad_plugins:
nomad-driver-podman:
config:
volumes:
enabled: true
selinuxlabel: z
recover_stopped: true
```

### `nomad_group_name`

- Ansible group that contains all cluster nodes
Expand Down Expand Up @@ -496,7 +528,12 @@ in many Ansible versions, so this feature might not always work.

### `nomad_vault_token`

- Vault token used by nomad
- Vault token used by nomad. Will only be installed on servers.
- Default value: **""**

### `nomad_vault_namespace`

- Vault namespace used by nomad
- Default value: **""**

### `nomad_docker_enable`
Expand Down Expand Up @@ -689,6 +726,32 @@ in many Ansible versions, so this feature might not always work.
- Specifies a special tag which will be used to select a Circonus Broker when a Broker ID is not provided. The best use of this is to as a hint for which broker should be used based on where this particular instance is running (e.g. a specific geographic location or datacenter, dc:sfo).
- Default value: ""

### `nomad_autopilot`

- Enable Nomad Autopilot
- To enable Autopilot features (with the exception of dead server cleanup), the raft_protocol setting in the server stanza must be set to 3 on all servers, see parameter nomad_raft_protocol
- Default value: **false**

### `nomad_autopilot_cleanup_dead_servers`

- Specifies automatic removal of dead server nodes periodically and whenever a new server is added to the cluster.
- Default value: **true**

### `nomad_autopilot_last_contact_threshold`

- Specifies the maximum amount of time a server can go without contact from the leader before being considered unhealthy.
- Default value: **200ms**

### `nomad_autopilot_max_trailing_logs`

- Specifies the maximum number of log entries that a server can trail the leader by before being considered unhealthy.
- Default value: **250**

### `nomad_autopilot_server_stabilization_time`

- Specifies the minimum amount of time a server must be stable in the 'healthy' state before being added to the cluster. Only takes effect if all servers are running Raft protocol version 3 or higher.
- Default value: **10s**

#### Custom Configuration Section

As Nomad loads the configuration from files and directories in lexical order,
Expand Down
19 changes: 18 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ os_supported_matrix:
nomad_debug: false

### Package
nomad_version: "{{ lookup('env','NOMAD_VERSION') | default('0.10.3', true) }}"
nomad_version: "{{ lookup('env','NOMAD_VERSION') | default('0.12.1', true) }}"
nomad_architecture_map:
amd64: amd64
x86_64: amd64
Expand All @@ -36,11 +36,18 @@ nomad_architecture: "{{ nomad_architecture_map[ansible_architecture] }}"
nomad_pkg: "nomad_{{ nomad_version }}_linux_{{nomad_architecture}}.zip"
nomad_zip_url: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_linux_{{nomad_architecture}}.zip"
nomad_checksum_file_url: "https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version}}_SHA256SUMS"
nomad_podman_enable: false
nomad_podman_version: "{{ lookup('env','NOMAD_PODMAN_VERSION') | default('0.1.0', true) }}"
nomad_podman_pkg: "nomad-driver-podman_{{ nomad_podman_version }}_linux_{{nomad_architecture}}.zip"
nomad_podman_url: "https://releases.hashicorp.com/nomad-driver-podman/{{ nomad_podman_version }}"
nomad_podman_zip_url: "{{ nomad_podman_url }}/{{ nomad_podman_pkg }}"
nomad_podman_checksum_file_url: "{{ nomad_podman_url }}/nomad-driver-podman_{{ nomad_podman_version }}_SHA256SUMS"

### Paths
nomad_bin_dir: "/usr/local/bin"
nomad_config_dir: "/etc/nomad.d"
nomad_data_dir: "/var/nomad"
nomad_plugin_dir: "{{ nomad_data_dir }}/plugins"
nomad_lockfile: "/var/lock/subsys/nomad"
nomad_run_dir: "/var/run/nomad"

Expand Down Expand Up @@ -75,7 +82,9 @@ nomad_num_schedulers: "{{ ansible_processor_vcpus }}"
nomad_node_gc_threshold: "24h"
nomad_job_gc_threshold: "4h"
nomad_eval_gc_threshold: "1h"
nomad_deployment_gc_threshold: "1h"
nomad_encrypt: ""
nomad_raft_protocol: 2

#### Client settings
nomad_node_class: ""
Expand All @@ -97,6 +106,7 @@ nomad_options: {}
nomad_meta: {}
nomad_bootstrap_expect: "{{ nomad_servers | count or 3 }}"
nomad_chroot_env: false
nomad_plugins: {}

### Addresses
nomad_bind_address: "{{ hostvars[inventory_hostname]['ansible_'+ nomad_iface ]['ipv4']['address'] }}"
Expand Down Expand Up @@ -152,6 +162,7 @@ nomad_vault_key_file: ""
nomad_vault_tls_server_name: ""
nomad_vault_tls_skip_verify: false
nomad_vault_token: ""
nomad_vault_namespace: ""

### Docker
nomad_docker_enable: "{{ lookup('env','NOMAD_DOCKER_ENABLE') | default('false', true) }}"
Expand All @@ -165,3 +176,9 @@ nomad_key_file: ""
nomad_rpc_upgrade_mode: false
nomad_verify_server_hostname: true
nomad_verify_https_client: true

### Autopilot
nomad_autopilot_cleanup_dead_servers: true
nomad_autopilot_last_contact_threshold: "200ms"
nomad_autopilot_max_trailing_logs: 250
nomad_autopilot_server_stabilization_time: "10s"
2 changes: 1 addition & 1 deletion examples/README_VAGRANT.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ BOX_NAME="centos/7" vagrant up
## Notes

1. This project functions with the following software versions:
* Nomad version 0.10.3
* Nomad version 0.12.1
* Ansible version 2.8.0
* VirtualBox version 5.2.30
* Vagrant version 2.2.4
Expand Down
18 changes: 8 additions & 10 deletions molecule/_shared/base.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
---
scenario:
test_sequence:
- lint
# - lint
- syntax
- create
- prepare
- converge
- idempotence
# - idempotence
- verify
- destroy
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
lint: |
set -e
yamllint .
ansible-lint
provisioner:
name: ansible
config_options:
Expand All @@ -31,12 +33,8 @@ provisioner:
converge: ../_shared/playbook.yml
inventory:
group_vars:
consul_instances:
consul_node_role: bootstrap
lint:
name: ansible-lint
nomad_instances:
nomad_node_role: bootstrap
verifier:
name: testinfra
directory: ../_shared/tests
lint:
name: flake8
22 changes: 9 additions & 13 deletions molecule/_shared/tests/test_default.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import os

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
"""Role testing files using testinfra."""


def test_hosts_file(host):
f = host.file('/etc/hosts')
"""Validate /etc/hosts file."""
f = host.file("/etc/hosts")

assert f.exists
assert f.user == 'root'
assert f.group == 'root'
assert f.user == "root"
assert f.group == "root"


def test_service(host):
consul = host.service('consul')
"""Validate nomad service."""
nomad = host.service('nomad')

assert consul.is_running
# disabled due to fail on debian 9
# assert consul.is_enabled
#assert nomad.is_running ## TODO Nomad service is not starting in container
assert nomad.is_enabled
6 changes: 5 additions & 1 deletion molecule/centos-6/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ scenario:
platforms:
- name: centos-6
groups:
- consul_instances
- nomad_instances
image: dokken/centos-6
dockerfile: ../_shared/Dockerfile.j2
capabilities:
- SYS_ADMIN
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: yes
5 changes: 4 additions & 1 deletion molecule/centos-7/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ scenario:
platforms:
- name: centos-7
groups:
- consul_instances
- nomad_instances
image: dokken/centos-7
command: /lib/systemd/systemd
dockerfile: ../_shared/Dockerfile.j2
capabilities:
- SYS_ADMIN
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: yes
5 changes: 4 additions & 1 deletion molecule/centos-8/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ scenario:
platforms:
- name: centos-8
groups:
- consul_instances
- nomad_instances
image: dokken/centos-8
command: /lib/systemd/systemd
dockerfile: ../_shared/Dockerfile.j2
capabilities:
- SYS_ADMIN
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: yes
3 changes: 2 additions & 1 deletion molecule/debian-10/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ scenario:
platforms:
- name: debian-10
groups:
- consul_instances
- nomad_instances
image: dokken/debian-10
command: /lib/systemd/systemd
dockerfile: ../_shared/Dockerfile.j2
Expand All @@ -13,3 +13,4 @@ platforms:
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: yes
Loading

0 comments on commit 0a627fb

Please sign in to comment.