Added database container and proved connectivity. Logic needs to be changed for HA.

This commit is contained in:
Xan Manning 2020-01-11 19:20:52 +00:00
parent 734e49a7e5
commit c3ae2b79eb
16 changed files with 41 additions and 13 deletions

View File

@ -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

View File

@ -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:

View File

@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: node*
become: true
vars:
molecule_is_test: true

View File

@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: node*
become: true
vars:
molecule_is_test: true

View File

@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: node*
become: true
vars:
molecule_is_test: true

View File

@ -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

View File

@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: node*
become: true
vars:
molecule_is_test: true

View File

@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: node*
become: true
vars:
molecule_is_test: true

View File

@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: node*
become: true
vars:
molecule_is_test: true

View File

@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: node*
become: true
vars:
molecule_is_test: true

View File

@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: node*
become: true
vars:
molecule_is_test: true

View File

@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: node*
become: true
vars:
molecule_is_test: true

View File

@ -1,6 +1,6 @@
---
- name: Prepare
hosts: all
hosts: node1
become: true
tasks:
- name: Ensure a user group exists

View File

@ -1,6 +1,6 @@
---
- name: Prepare
hosts: all
hosts: node*
tasks:
- name: Debug Message
debug:

View File

@ -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)

View File

@ -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 }}