mirror of
https://github.com/PyratLabs/ansible-role-k3s.git
synced 2024-11-25 12:15:51 +01:00
Refactoring tests for Molecule v3.
This commit is contained in:
parent
72638e8e3d
commit
c63d984301
@ -1,2 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
skip_list:
|
skip_list:
|
||||||
- '106'
|
- '106'
|
||||||
|
22
.travis.yml
22
.travis.yml
@ -16,37 +16,31 @@ env:
|
|||||||
|
|
||||||
# Test installing docker
|
# Test installing docker
|
||||||
- MOLECULE_DISTRO: geerlingguy/docker-centos7-ansible:latest
|
- MOLECULE_DISTRO: geerlingguy/docker-centos7-ansible:latest
|
||||||
MOLECULE_PLAYBOOK: playbook-docker.yml
|
MOLECULE_SCENARIO: docker
|
||||||
- MOLECULE_DISTRO: geerlingguy/docker-ubuntu1804-ansible:latest
|
- MOLECULE_DISTRO: geerlingguy/docker-ubuntu1804-ansible:latest
|
||||||
MOLECULE_PLAYBOOK: playbook-docker.yml
|
MOLECULE_SCENARIO: docker
|
||||||
- MOLECULE_DISTRO: geerlingguy/docker-amazonlinux2-ansible:latest
|
- MOLECULE_DISTRO: geerlingguy/docker-amazonlinux2-ansible:latest
|
||||||
MOLECULE_PLAYBOOK: playbook-docker.yml
|
MOLECULE_SCENARIO: docker
|
||||||
|
|
||||||
# Test using alternate port and using wireguard as the flannel backend
|
|
||||||
- MOLECULE_DISTRO: geerlingguy/docker-centos7-ansible:latest
|
|
||||||
MOLECULE_PLAYBOOK: playbook-docker-altport-wireguard.yml
|
|
||||||
|
|
||||||
# Test disabling all deployments
|
# Test disabling all deployments
|
||||||
- MOLECULE_DISTRO: geerlingguy/docker-fedora31-ansible:latest
|
- MOLECULE_DISTRO: geerlingguy/docker-fedora31-ansible:latest
|
||||||
MOLECULE_PLAYBOOK: playbook-no-deploy.yml
|
MOLECULE_SCENARIO: nodeploy
|
||||||
|
|
||||||
# Test multiple masters in control plane with PostgreSQL
|
# Test multiple masters in control plane with PostgreSQL
|
||||||
- MOLECULE_DISTRO: geerlingguy/docker-fedora29-ansible:latest
|
- MOLECULE_DISTRO: geerlingguy/docker-fedora29-ansible:latest
|
||||||
MOLECULE_SCENARIO: highavailability
|
MOLECULE_SCENARIO: highavailabilitydb
|
||||||
|
|
||||||
# Test multiple masters with auto deploying manifests
|
# Test multiple masters with auto deploying manifests
|
||||||
- MOLECULE_DISTRO: geerlingguy/docker-fedora30-ansible:latest
|
- MOLECULE_DISTRO: geerlingguy/docker-fedora30-ansible:latest
|
||||||
MOLECULE_SCENARIO: highavailability
|
MOLECULE_SCENARIO: autodeploy
|
||||||
MOLECULE_PLAYBOOK: playbook-auto-deploying-manifests.yml
|
|
||||||
|
|
||||||
# Test multiple masters in control plane with Etcd
|
# Test multiple masters in control plane with Etcd
|
||||||
- MOLECULE_DISTRO: geerlingguy/docker-centos8-ansible:latest
|
- MOLECULE_DISTRO: geerlingguy/docker-centos8-ansible:latest
|
||||||
MOLECULE_SCENARIO: highavailability
|
MOLECULE_SCENARIO: highavailabilityetcd
|
||||||
MOLECULE_PLAYBOOK: playbook-etcd.yml
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
# Install test dependencies.
|
# Install test dependencies.
|
||||||
- pip install molecule[docker] docker jmespath ansible-lint
|
- pip install -r molecule/requirements.txt
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
# Use actual Ansible Galaxy role name for the project directory.
|
# Use actual Ansible Galaxy role name for the project directory.
|
||||||
|
22
.yamllint
22
.yamllint
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
|
# Based on ansible-lint config
|
||||||
extends: default
|
extends: default
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
@ -9,5 +9,25 @@ rules:
|
|||||||
brackets:
|
brackets:
|
||||||
max-spaces-inside: 1
|
max-spaces-inside: 1
|
||||||
level: error
|
level: error
|
||||||
|
colons:
|
||||||
|
max-spaces-after: -1
|
||||||
|
level: error
|
||||||
|
commas:
|
||||||
|
max-spaces-after: -1
|
||||||
|
level: error
|
||||||
|
comments: disable
|
||||||
|
comments-indentation: disable
|
||||||
|
document-start: disable
|
||||||
|
empty-lines:
|
||||||
|
max: 3
|
||||||
|
level: error
|
||||||
|
hyphens:
|
||||||
|
level: error
|
||||||
|
indentation: disable
|
||||||
|
key-duplicates: enable
|
||||||
line-length: disable
|
line-length: disable
|
||||||
|
new-line-at-end-of-file: disable
|
||||||
|
new-lines:
|
||||||
|
type: unix
|
||||||
|
trailing-spaces: disable
|
||||||
truthy: disable
|
truthy: disable
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
---
|
---
|
||||||
- name: Converge
|
- name: Converge
|
||||||
hosts: all
|
hosts: node*
|
||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
molecule_is_test: true
|
molecule_is_test: true
|
||||||
|
k3s_build_cluster: false
|
||||||
k3s_server_manifests_templates:
|
k3s_server_manifests_templates:
|
||||||
- "molecule/default/templates/00-ns-monitoring.yml.j2"
|
- "molecule/highavailability/templates/00-ns-monitoring.yml.j2"
|
||||||
roles:
|
roles:
|
||||||
- role: xanmanning.k3s
|
- role: xanmanning.k3s
|
44
molecule/autodeploy/molecule.yml
Normal file
44
molecule/autodeploy/molecule.yml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint: |
|
||||||
|
set -e
|
||||||
|
yamllint -s .
|
||||||
|
ansible-lint
|
||||||
|
platforms:
|
||||||
|
- name: node1
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
- name: node2
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
- name: node3
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
options:
|
||||||
|
verbose: true
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
9
molecule/autodeploy/verify.yml
Normal file
9
molecule/autodeploy/verify.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
# This is an example playbook to execute Ansible tests.
|
||||||
|
|
||||||
|
- name: Verify
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Example assertion
|
||||||
|
assert:
|
||||||
|
that: true
|
@ -6,7 +6,7 @@ driver:
|
|||||||
name: docker
|
name: docker
|
||||||
lint: |
|
lint: |
|
||||||
set -e
|
set -e
|
||||||
yamllint .
|
yamllint -s .
|
||||||
ansible-lint
|
ansible-lint
|
||||||
platforms:
|
platforms:
|
||||||
- name: node1
|
- name: node1
|
||||||
@ -40,6 +40,5 @@ provisioner:
|
|||||||
name: ansible
|
name: ansible
|
||||||
options:
|
options:
|
||||||
verbose: true
|
verbose: true
|
||||||
playbooks:
|
verifier:
|
||||||
prepare: ${MOLECULE_PREPARE_PLAYBOOK:-prepare.yml}
|
name: ansible
|
||||||
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Converge
|
|
||||||
hosts: all
|
|
||||||
become: true
|
|
||||||
vars:
|
|
||||||
molecule_is_test: true
|
|
||||||
k3s_use_docker: true
|
|
||||||
roles:
|
|
||||||
- role: xanmanning.k3s
|
|
44
molecule/docker/molecule.yml
Normal file
44
molecule/docker/molecule.yml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint: |
|
||||||
|
set -e
|
||||||
|
yamllint -s .
|
||||||
|
ansible-lint
|
||||||
|
platforms:
|
||||||
|
- name: node1
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
- name: node2
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
- name: node3
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
options:
|
||||||
|
verbose: true
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
8
molecule/docker/prepare.yml
Normal file
8
molecule/docker/prepare.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Ensure apt cache is updated
|
||||||
|
apt:
|
||||||
|
update_cache: true
|
||||||
|
when: ansible_pkg_mgr == 'apt'
|
@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Converge
|
|
||||||
hosts: node*
|
|
||||||
become: true
|
|
||||||
vars:
|
|
||||||
molecule_is_test: true
|
|
||||||
k3s_control_node_address: loadbalancer
|
|
||||||
k3s_datastore_endpoint: "postgres://postgres:verybadpass@database:5432/postgres?sslmode=disable"
|
|
||||||
k3s_server_manifests_templates:
|
|
||||||
- "molecule/highavailability/templates/00-ns-monitoring.yml.j2"
|
|
||||||
pre_tasks:
|
|
||||||
- name: Set each node to be a control node
|
|
||||||
set_fact:
|
|
||||||
k3s_control_node: true
|
|
||||||
when: inventory_hostname in ['node2', 'node3']
|
|
||||||
roles:
|
|
||||||
- role: xanmanning.k3s
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Converge
|
|
||||||
hosts: node*
|
|
||||||
become: true
|
|
||||||
vars:
|
|
||||||
molecule_is_test: true
|
|
||||||
k3s_release_version: v1.18
|
|
||||||
k3s_dqlite_datastore: true
|
|
||||||
k3s_secrets_encryption: true
|
|
||||||
k3s_use_experimental: true
|
|
||||||
k3s_use_unsupported_config: true
|
|
||||||
pre_tasks:
|
|
||||||
- name: Set each node to be a control node
|
|
||||||
set_fact:
|
|
||||||
k3s_control_node: true
|
|
||||||
when: inventory_hostname in ['node2', 'node3']
|
|
||||||
roles:
|
|
||||||
- role: xanmanning.k3s
|
|
@ -6,7 +6,7 @@ driver:
|
|||||||
name: docker
|
name: docker
|
||||||
lint: |
|
lint: |
|
||||||
set -e
|
set -e
|
||||||
yamllint .
|
yamllint -s .
|
||||||
ansible-lint
|
ansible-lint
|
||||||
platforms:
|
platforms:
|
||||||
- name: node1
|
- name: node1
|
||||||
@ -55,6 +55,3 @@ provisioner:
|
|||||||
name: ansible
|
name: ansible
|
||||||
options:
|
options:
|
||||||
verbose: true
|
verbose: true
|
||||||
playbooks:
|
|
||||||
prepare: ${MOLECULE_PREPARE_PLAYBOOK:-prepare.yml}
|
|
||||||
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
|
|
13
molecule/highavailabilityetcd/haproxy-loadbalancer.conf.j2
Normal file
13
molecule/highavailabilityetcd/haproxy-loadbalancer.conf.j2
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
frontend loadbalancer
|
||||||
|
bind *:6443
|
||||||
|
mode tcp
|
||||||
|
default_backend control_nodes
|
||||||
|
timeout client 1m
|
||||||
|
|
||||||
|
backend control_nodes
|
||||||
|
mode tcp
|
||||||
|
balance roundrobin
|
||||||
|
server node2 node2:6443
|
||||||
|
server node3 node3:6443
|
||||||
|
timeout connect 30s
|
||||||
|
timeout server 30m
|
49
molecule/highavailabilityetcd/molecule.yml
Normal file
49
molecule/highavailabilityetcd/molecule.yml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint: |
|
||||||
|
set -e
|
||||||
|
yamllint -s .
|
||||||
|
ansible-lint
|
||||||
|
platforms:
|
||||||
|
- name: node1
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
- name: node2
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
- name: node3
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
- name: loadbalancer
|
||||||
|
image: geerlingguy/docker-centos8-ansible:latest
|
||||||
|
pre_build_image: true
|
||||||
|
ports:
|
||||||
|
- "6443:6443"
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
options:
|
||||||
|
verbose: true
|
30
molecule/highavailabilityetcd/prepare.yml
Normal file
30
molecule/highavailabilityetcd/prepare.yml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: loadbalancer
|
||||||
|
tasks:
|
||||||
|
- name: Ensure apt cache is updated
|
||||||
|
apt:
|
||||||
|
update_cache: true
|
||||||
|
when: ansible_pkg_mgr == 'apt'
|
||||||
|
|
||||||
|
- name: Ensure HAProxy is installed
|
||||||
|
package:
|
||||||
|
name: haproxy
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure HAProxy config directory exists
|
||||||
|
file:
|
||||||
|
path: /usr/local/etc/haproxy
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Ensure HAProxy is configured
|
||||||
|
template:
|
||||||
|
src: haproxy-loadbalancer.conf.j2
|
||||||
|
dest: /usr/local/etc/haproxy/haproxy.cfg
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: Ensure HAProxy service is started
|
||||||
|
command: haproxy -D -f /usr/local/etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
|
||||||
|
args:
|
||||||
|
creates: /var/run/haproxy.pid
|
44
molecule/nodeploy/molecule.yml
Normal file
44
molecule/nodeploy/molecule.yml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint: |
|
||||||
|
set -e
|
||||||
|
yamllint -s .
|
||||||
|
ansible-lint
|
||||||
|
platforms:
|
||||||
|
- name: node1
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
- name: node2
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
- name: node3
|
||||||
|
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
|
||||||
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
privileged: true
|
||||||
|
pre_build_image: ${MOLECULE_PREBUILT:-true}
|
||||||
|
networks:
|
||||||
|
- name: k3snet
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
options:
|
||||||
|
verbose: true
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
9
molecule/nodeploy/verify.yml
Normal file
9
molecule/nodeploy/verify.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
# This is an example playbook to execute Ansible tests.
|
||||||
|
|
||||||
|
- name: Verify
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Example assertion
|
||||||
|
assert:
|
||||||
|
that: true
|
6
molecule/requirements.txt
Normal file
6
molecule/requirements.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
-r ../requirements.txt
|
||||||
|
|
||||||
|
molecule[docker]>=3.1.2
|
||||||
|
docker>=4.3.1
|
||||||
|
yamllint>=1.25.0
|
||||||
|
ansible-lint>=4.3.5
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
jmespath>=0.10.0
|
Loading…
Reference in New Issue
Block a user