diff --git a/.travis.yml b/.travis.yml index 5664c3a..60015f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,10 @@ env: - MOLECULE_DISTRO: geerlingguy/docker-fedora31-ansible:latest MOLECULE_PLAYBOOK: playbook-no-deploy.yml + # Test multiple masters in control plane with PostgreSQL + - MOLECULE_DISTRO: geerlingguy/docker-centos8-ansible:latest + MOLECULE_PLAYBOOK: playbook-ha-postgres.yml + install: # Install test dependencies. - pip install molecule docker jmespath diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index b0173c6..5a3ae42 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -34,6 +34,14 @@ platforms: pre_build_image: ${MOLECULE_PREBUILT:-true} networks: - name: k3snet + - name: database + image: postgres:11-alpine + pre_build_image: true + command: "postgres" + env: + POSTGRES_PASSWORD: "verybadpass" + networks: + - name: k3snet provisioner: name: ansible options: diff --git a/molecule/default/playbook-docker-altport-wireguard.yml b/molecule/default/playbook-docker-altport-wireguard.yml index 1db8114..e417c05 100644 --- a/molecule/default/playbook-docker-altport-wireguard.yml +++ b/molecule/default/playbook-docker-altport-wireguard.yml @@ -1,6 +1,6 @@ --- - name: Converge - hosts: all + hosts: node* become: true vars: molecule_is_test: true diff --git a/molecule/default/playbook-docker.yml b/molecule/default/playbook-docker.yml index a780b33..9d93375 100644 --- a/molecule/default/playbook-docker.yml +++ b/molecule/default/playbook-docker.yml @@ -1,6 +1,6 @@ --- - name: Converge - hosts: all + hosts: node* become: true vars: molecule_is_test: true diff --git a/molecule/default/playbook-download.yml b/molecule/default/playbook-download.yml index 9e3efc4..5f869bc 100644 --- a/molecule/default/playbook-download.yml +++ b/molecule/default/playbook-download.yml @@ -1,6 +1,6 @@ --- - name: Converge - hosts: all + hosts: node* become: true vars: molecule_is_test: true diff --git a/molecule/default/playbook-ha-postgres.yml b/molecule/default/playbook-ha-postgres.yml new file mode 100644 index 0000000..ec17daa --- /dev/null +++ b/molecule/default/playbook-ha-postgres.yml @@ -0,0 +1,13 @@ +--- +- name: Converge + hosts: node* + become: true + vars: + molecule_is_test: true + k3s_datastore_endpoint: "postgres://postgres:verybadpass@database:5432/postgres?sslmode=disable" + pre_tasks: + - name: Set each node to be a control node + set_fact: + k3s_control_node: true + roles: + - role: xanmanning.k3s diff --git a/molecule/default/playbook-no-deploy.yml b/molecule/default/playbook-no-deploy.yml index 16a8ab4..fece13b 100644 --- a/molecule/default/playbook-no-deploy.yml +++ b/molecule/default/playbook-no-deploy.yml @@ -1,6 +1,6 @@ --- - name: Converge - hosts: all + hosts: node* become: true vars: molecule_is_test: true diff --git a/molecule/default/playbook-restart-cluster.yml b/molecule/default/playbook-restart-cluster.yml index d89782b..45add58 100644 --- a/molecule/default/playbook-restart-cluster.yml +++ b/molecule/default/playbook-restart-cluster.yml @@ -1,6 +1,6 @@ --- - name: Converge - hosts: all + hosts: node* become: true vars: molecule_is_test: true diff --git a/molecule/default/playbook-start-cluster.yml b/molecule/default/playbook-start-cluster.yml index e206333..bc9fbbf 100644 --- a/molecule/default/playbook-start-cluster.yml +++ b/molecule/default/playbook-start-cluster.yml @@ -1,6 +1,6 @@ --- - name: Converge - hosts: all + hosts: node* become: true vars: molecule_is_test: true diff --git a/molecule/default/playbook-stop-cluster.yml b/molecule/default/playbook-stop-cluster.yml index 477b431..1c1ab52 100644 --- a/molecule/default/playbook-stop-cluster.yml +++ b/molecule/default/playbook-stop-cluster.yml @@ -1,6 +1,6 @@ --- - name: Converge - hosts: all + hosts: node* become: true vars: molecule_is_test: true diff --git a/molecule/default/playbook-version.yml b/molecule/default/playbook-version.yml index 740d9c9..5f8cac9 100644 --- a/molecule/default/playbook-version.yml +++ b/molecule/default/playbook-version.yml @@ -1,6 +1,6 @@ --- - name: Converge - hosts: all + hosts: node* become: true vars: molecule_is_test: true diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml index 394481e..92c2184 100644 --- a/molecule/default/playbook.yml +++ b/molecule/default/playbook.yml @@ -1,6 +1,6 @@ --- - name: Converge - hosts: all + hosts: node* become: true vars: molecule_is_test: true diff --git a/molecule/default/prepare-rootless.yml b/molecule/default/prepare-rootless.yml index df685fb..e517e70 100644 --- a/molecule/default/prepare-rootless.yml +++ b/molecule/default/prepare-rootless.yml @@ -1,6 +1,6 @@ --- - name: Prepare - hosts: all + hosts: node1 become: true tasks: - name: Ensure a user group exists diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 5aed1ec..567499e 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -1,6 +1,6 @@ --- - name: Prepare - hosts: all + hosts: node* tasks: - name: Debug Message debug: diff --git a/tasks/validate/check-experimental-variables.yml b/tasks/validate/check-experimental-variables.yml index fc3c992..0132564 100644 --- a/tasks/validate/check-experimental-variables.yml +++ b/tasks/validate/check-experimental-variables.yml @@ -4,7 +4,7 @@ assert: that: - k3s_use_experimental is defined and k3s_use_experimental - - k3s_dqlite_datastore is defined and k3s_use_experimental success_msg: "Experimental variables are defined and enabled." fail_msg: "Experimental variables have been configured. If you want to use them ensure you set k3s_use_experimental" - when: k3s_non_root is defined and k3s_non_root + when: (k3s_non_root is defined and k3s_non_root) + or (k3s_dqlite_datastore is defined and k3s_dqlite_datastore) diff --git a/templates/k3s.service.j2 b/templates/k3s.service.j2 index 1a127e9..8b1dfb5 100644 --- a/templates/k3s.service.j2 +++ b/templates/k3s.service.j2 @@ -54,6 +54,9 @@ ExecStart={{ k3s_install_dir }}/k3s {% if k3s_cluster_domain is defined and k3s_cluster_domain != "cluster.local" %} --cluster-domain {{ k3s_cluster_domain }} {% endif %} + {% if k3s_datastore_endpoint is defined and k3s_datastore_endpoint %} + --datastore-endpoint "{{ k3s_datastore_endpoint }}" + {% endif %} {% else %} agent --server https://{{ k3s_control_node_address }}:{{ k3s_https_port }}