root
5 years ago
28 changed files with 947 additions and 0 deletions
@ -0,0 +1,4 @@ |
|||
### Useful command-line information for virtual lab usage |
|||
|
|||
Command for checking the docker node status: ```docker node ls``` |
|||
Command for using and attaching to LXC container (e.g. to 'worker1'): ```lxc-attach --name worker1```. |
@ -0,0 +1,7 @@ |
|||
### Installlation instructions |
|||
Run as *root* user the following commands to automatically install the virtual lab and provision all the \ |
|||
necessary elements for the containerized swarm setup of galera cluster. |
|||
|
|||
```git clone https://git.swarmlab.io:3000/repo/create |
|||
make |
|||
``` |
@ -0,0 +1,13 @@ |
|||
all: preautomation provision config swarm_deploy |
|||
|
|||
preautomation: |
|||
/bin/bash ./ansible_install.sh |
|||
|
|||
provision: |
|||
/bin/bash ./ansible_provisioning.sh |
|||
|
|||
config: |
|||
/bin/bash ./ansible_swarm_config.sh |
|||
|
|||
swarm_deploy: |
|||
/bin/bash docker stack deploy -c swarm-galera.yml stack |
@ -0,0 +1,5 @@ |
|||
#!/bin/bash |
|||
[ `id -u` -ne 0 ] && exit 1 |
|||
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list |
|||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 |
|||
apt update && apt install ansible |
@ -0,0 +1,4 @@ |
|||
#!/bin/bash |
|||
[ `id -u` -ne 0 ] && exit 1 |
|||
ssh-keygen -t rsa -b 4096 -N '' -f ~/.ssh/id_rsa |
|||
ansible-playbook -i inventory/hosts --skip-tags swarm --diff -v galera.yml |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
[ `id -u` -ne 0 ] && exit 1 |
|||
ansible-playbook -i inventory/hosts --tags swarm --diff -v galera.yml |
@ -0,0 +1,7 @@ |
|||
[manager] |
|||
127.0.0.1 ansible_connection=local |
|||
|
|||
[workers] |
|||
10.0.3.100 ansible_ssh_user=root |
|||
10.0.3.101 ansible_ssh_user=root |
|||
#10.0.3.102 ansible_ssh_user=root |
@ -0,0 +1,29 @@ |
|||
--- |
|||
language: python |
|||
python: "2.7" |
|||
|
|||
# Use the new container infrastructure |
|||
sudo: false |
|||
|
|||
# Install ansible |
|||
addons: |
|||
apt: |
|||
packages: |
|||
- python-pip |
|||
|
|||
install: |
|||
# Install ansible |
|||
- pip install ansible |
|||
|
|||
# Check ansible version |
|||
- ansible --version |
|||
|
|||
# Create ansible.cfg with correct roles_path |
|||
- printf '[defaults]\nroles_path=../' >ansible.cfg |
|||
|
|||
script: |
|||
# Basic role syntax check |
|||
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check |
|||
|
|||
notifications: |
|||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ |
@ -0,0 +1,38 @@ |
|||
Role Name |
|||
========= |
|||
|
|||
A brief description of the role goes here. |
|||
|
|||
Requirements |
|||
------------ |
|||
|
|||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. |
|||
|
|||
Role Variables |
|||
-------------- |
|||
|
|||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. |
|||
|
|||
Dependencies |
|||
------------ |
|||
|
|||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. |
|||
|
|||
Example Playbook |
|||
---------------- |
|||
|
|||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: |
|||
|
|||
- hosts: servers |
|||
roles: |
|||
- { role: username.rolename, x: 42 } |
|||
|
|||
License |
|||
------- |
|||
|
|||
BSD |
|||
|
|||
Author Information |
|||
------------------ |
|||
|
|||
An optional section for the role authors to include contact information, or a website (HTML is not allowed). |
@ -0,0 +1,2 @@ |
|||
--- |
|||
# defaults file for roles/galera_swarm |
@ -0,0 +1,16 @@ |
|||
--- |
|||
# handlers file for roles/galera_swarm |
|||
- name: Restart lxc |
|||
systemd: |
|||
name: lxc |
|||
state: restarted |
|||
|
|||
- name: Restart lxc-net |
|||
systemd: |
|||
name: lxc-net |
|||
state: restarted |
|||
|
|||
- name: Restart docker |
|||
systemd: |
|||
name: docker |
|||
state: restarted |
@ -0,0 +1,365 @@ |
|||
galaxy_info: |
|||
author: your name |
|||
description: your description |
|||
company: your company (optional) |
|||
|
|||
# If the issue tracker for your role is not on github, uncomment the |
|||
# next line and provide a value |
|||
# issue_tracker_url: http://example.com/issue/tracker |
|||
|
|||
# Some suggested licenses: |
|||
# - BSD (default) |
|||
# - MIT |
|||
# - GPLv2 |
|||
# - GPLv3 |
|||
# - Apache |
|||
# - CC-BY |
|||
license: license (GPLv2, CC-BY, etc) |
|||
|
|||
min_ansible_version: 1.2 |
|||
|
|||
# Optionally specify the branch Galaxy will use when accessing the GitHub |
|||
# repo for this role. During role install, if no tags are available, |
|||
# Galaxy will use this branch. During import Galaxy will access files on |
|||
# this branch. If travis integration is cofigured, only notification for this |
|||
# branch will be accepted. Otherwise, in all cases, the repo's default branch |
|||
# (usually master) will be used. |
|||
#github_branch: |
|||
|
|||
# |
|||
# Below are all platforms currently available. Just uncomment |
|||
# the ones that apply to your role. If you don't see your |
|||
# platform on this list, let us know and we'll get it added! |
|||
# |
|||
#platforms: |
|||
#- name: Amazon Linux 2 |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: TMOS |
|||
# versions: |
|||
# - all |
|||
# - 12.1 |
|||
# - 13.0 |
|||
# - 13.1 |
|||
# - 14.0 |
|||
#- name: OpenBSD |
|||
# versions: |
|||
# - all |
|||
# - 5.6 |
|||
# - 5.7 |
|||
# - 5.8 |
|||
# - 5.9 |
|||
# - 6.0 |
|||
# - 6.1 |
|||
# - 6.2 |
|||
# - 6.3 |
|||
# - 6.4 |
|||
# - 6.5 |
|||
# - 6.6 |
|||
# - 6.7 |
|||
#- name: AIX |
|||
# versions: |
|||
# - all |
|||
# - 6.1 |
|||
# - 7.1 |
|||
# - 7.2 |
|||
#- name: DellOS |
|||
# versions: |
|||
# - all |
|||
# - 10 |
|||
# - 6 |
|||
# - 9 |
|||
#- name: MacOSX |
|||
# versions: |
|||
# - all |
|||
# - 10.10 |
|||
# - 10.11 |
|||
# - 10.12 |
|||
# - 10.13 |
|||
# - 10.14 |
|||
# - 10.15 |
|||
# - 10.7 |
|||
# - 10.8 |
|||
# - 10.9 |
|||
#- name: Synology |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: Junos |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: Cumulus |
|||
# versions: |
|||
# - all |
|||
# - 2.5 |
|||
# - 3.0 |
|||
# - 3.1 |
|||
# - 3.2 |
|||
# - 3.3 |
|||
# - 3.4 |
|||
# - 3.5 |
|||
#- name: GenericBSD |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: os10 |
|||
# versions: |
|||
# - all |
|||
# - all |
|||
# - any |
|||
#- name: Void Linux |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: GenericLinux |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: NXOS |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: DragonFlyBSD |
|||
# versions: |
|||
# - all |
|||
# - 5.2 |
|||
# - 5.4 |
|||
#- name: macOS |
|||
# versions: |
|||
# - all |
|||
# - High-Sierra |
|||
# - Sierra |
|||
#- name: Gentoo |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: IOS |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: Amazon |
|||
# versions: |
|||
# - all |
|||
# - 2013.03 |
|||
# - 2013.09 |
|||
# - 2014.03 |
|||
# - 2014.09 |
|||
# - 2015.03 |
|||
# - 2015.09 |
|||
# - 2016.03 |
|||
# - 2016.09 |
|||
# - 2017.03 |
|||
# - 2017.09 |
|||
# - 2017.12 |
|||
# - 2018.03 |
|||
# - Candidate |
|||
#- name: ArchLinux |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: FreeBSD |
|||
# versions: |
|||
# - all |
|||
# - 10.0 |
|||
# - 10.1 |
|||
# - 10.2 |
|||
# - 10.3 |
|||
# - 10.4 |
|||
# - 11.0 |
|||
# - 11.1 |
|||
# - 11.2 |
|||
# - 11.3 |
|||
# - 12.0 |
|||
# - 12.1 |
|||
# - 8.0 |
|||
# - 8.1 |
|||
# - 8.2 |
|||
# - 8.3 |
|||
# - 8.4 |
|||
# - 9.0 |
|||
# - 9.1 |
|||
# - 9.1 |
|||
# - 9.2 |
|||
# - 9.3 |
|||
#- name: Ubuntu |
|||
# versions: |
|||
# - all |
|||
# - artful |
|||
# - bionic |
|||
# - cosmic |
|||
# - cuttlefish |
|||
# - disco |
|||
# - eoan |
|||
# - focal |
|||
# - lucid |
|||
# - maverick |
|||
# - natty |
|||
# - oneiric |
|||
# - precise |
|||
# - quantal |
|||
# - raring |
|||
# - saucy |
|||
# - trusty |
|||
# - utopic |
|||
# - vivid |
|||
# - wily |
|||
# - xenial |
|||
# - yakkety |
|||
# - zesty |
|||
#- name: Fedora |
|||
# versions: |
|||
# - all |
|||
# - 16 |
|||
# - 17 |
|||
# - 18 |
|||
# - 19 |
|||
# - 20 |
|||
# - 21 |
|||
# - 22 |
|||
# - 23 |
|||
# - 24 |
|||
# - 25 |
|||
# - 26 |
|||
# - 27 |
|||
# - 28 |
|||
# - 29 |
|||
# - 30 |
|||
# - 31 |
|||
# - 32 |
|||
#- name: Debian |
|||
# versions: |
|||
# - all |
|||
# - bullseye |
|||
# - buster |
|||
# - etch |
|||
# - jessie |
|||
# - lenny |
|||
# - sid |
|||
# - squeeze |
|||
# - stretch |
|||
# - wheezy |
|||
#- name: Alpine |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: EL |
|||
# versions: |
|||
# - all |
|||
# - 5 |
|||
# - 6 |
|||
# - 7 |
|||
# - 8 |
|||
#- name: PAN-OS |
|||
# versions: |
|||
# - all |
|||
# - 7.1 |
|||
# - 8.0 |
|||
# - 8.1 |
|||
# - 9.0 |
|||
#- name: Windows |
|||
# versions: |
|||
# - all |
|||
# - 2008R2 |
|||
# - 2008x64 |
|||
# - 2008x86 |
|||
# - 2012 |
|||
# - 2012R2 |
|||
# - 2016 |
|||
# - 2019 |
|||
#- name: vSphere |
|||
# versions: |
|||
# - all |
|||
# - 5.5 |
|||
# - 6.0 |
|||
# - 6.5 |
|||
# - 6.7 |
|||
#- name: SmartOS |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: HardenedBSD |
|||
# versions: |
|||
# - all |
|||
# - 10 |
|||
# - 11 |
|||
#- name: opensuse |
|||
# versions: |
|||
# - all |
|||
# - 12.1 |
|||
# - 12.2 |
|||
# - 12.3 |
|||
# - 13.1 |
|||
# - 13.2 |
|||
# - 15.0 |
|||
# - 15.1 |
|||
# - 15.2 |
|||
# - 42.1 |
|||
# - 42.2 |
|||
# - 42.3 |
|||
#- name: aos |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: SLES |
|||
# versions: |
|||
# - all |
|||
# - 10SP3 |
|||
# - 10SP4 |
|||
# - 11 |
|||
# - 11SP1 |
|||
# - 11SP2 |
|||
# - 11SP3 |
|||
# - 11SP4 |
|||
# - 12 |
|||
# - 12SP1 |
|||
# - 15 |
|||
#- name: vCenter |
|||
# versions: |
|||
# - all |
|||
# - 5.5 |
|||
# - 6.0 |
|||
# - 6.5 |
|||
# - 6.7 |
|||
#- name: ClearLinux |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: GenericUNIX |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
#- name: Solaris |
|||
# versions: |
|||
# - all |
|||
# - 10 |
|||
# - 11.0 |
|||
# - 11.1 |
|||
# - 11.2 |
|||
# - 11.3 |
|||
#- name: Devuan |
|||
# versions: |
|||
# - all |
|||
# - ascii |
|||
# - beowulf |
|||
# - ceres |
|||
# - jessie |
|||
#- name: eos |
|||
# versions: |
|||
# - all |
|||
# - any |
|||
|
|||
galaxy_tags: [] |
|||
# List tags for your role here, one per line. A tag is |
|||
# a keyword that describes and categorizes the role. |
|||
# Users find roles by searching for tags. Be sure to |
|||
# remove the '[]' above if you add tags to this list. |
|||
# |
|||
# NOTE: A tag is limited to a single word comprised of |
|||
# alphanumeric characters. Maximum 20 tags per role. |
|||
|
|||
dependencies: [] |
|||
# List your role dependencies here, one per line. |
|||
# Be sure to remove the '[]' above if you add dependencies |
|||
# to this list. |
@ -0,0 +1,36 @@ |
|||
--- |
|||
- name: Copy galera template |
|||
template: |
|||
src: galera.cnf.j2 |
|||
dest: /opt/galera.cnf |
|||
owner: root |
|||
group: root |
|||
mode: '0644' |
|||
remote_src: no |
|||
|
|||
- name: Galera template fix |
|||
shell: sed -i "s/ /,/g;s/ 1/1/g;s/ "/"/g" /opt/galera.cnf |
|||
|
|||
#- name: set mysql options fact |
|||
# set_fact: |
|||
# extra_docker_options: "--wsrep-new-cluster" |
|||
# when: ansible_hostname == 'worker1' |
|||
|
|||
- name: Copy Dockerfile template |
|||
template: |
|||
src: Dockerfile.j2 |
|||
dest: /opt/Dockerfile |
|||
remote_src: no |
|||
|
|||
#- name: Build 'swarm-galera' image |
|||
# docker_image: |
|||
# name: 'swarm-galera' |
|||
# build: |
|||
# path: / |
|||
# tag: v1 |
|||
# source: build |
|||
|
|||
- name: Build image from Dockerfile |
|||
shell: docker build -t ubuntu:galera-node-{{ ansible_hostname }} . |
|||
args: |
|||
chdir: /opt |
@ -0,0 +1,28 @@ |
|||
--- |
|||
- name: Create debian containers for swarm |
|||
lxc_container: |
|||
name: "{{ item }}" |
|||
container_log: true |
|||
template: debian |
|||
state: stopped |
|||
fs_size: 2G |
|||
template_options: --release stretch -a amd64 |
|||
container_command: | |
|||
if [ ! -d ~/.ssh ]; then |
|||
mkdir ~/.ssh |
|||
echo "{{ lookup('file', my_ssh_key) }}" | tee -a ~/.ssh/authorized_keys |
|||
systemctl restart sshd |
|||
fi |
|||
with_items: |
|||
- "worker1" |
|||
- "worker2" |
|||
# - "worker3" |
|||
tags: lxc |
|||
|
|||
- name: Start lxc containers |
|||
shell: lxc-start --name {{ item }} |
|||
with_items: |
|||
- "worker1" |
|||
- "worker2" |
|||
# - "worker3" |
|||
tags: lxc |
@ -0,0 +1,20 @@ |
|||
--- |
|||
- name: lxc default template |
|||
template: |
|||
src: lxc_default.conf.j2 |
|||
dest: /etc/lxc/default.conf |
|||
remote_src: no |
|||
|
|||
- name: lxc dhcp template |
|||
template: |
|||
src: lxc_dhcp.conf.j2 |
|||
dest: /etc/lxc/dhcp.conf |
|||
remote_src: no |
|||
notify: Restart lxc |
|||
|
|||
- name: lxc-net template |
|||
template: |
|||
src: lxc_net.j2 |
|||
dest: /etc/default/lxc-net |
|||
remote_src: no |
|||
notify: Restart lxc-net |
@ -0,0 +1,46 @@ |
|||
--- |
|||
# tasks file for roles/galera_swarm |
|||
- name: Load in local SSH key path |
|||
set_fact: |
|||
my_ssh_key: "{{ lookup('env','HOME') }}/.ssh/id_rsa.pub" |
|||
when: inventory_hostname in groups['manager'] |
|||
tags: lxc |
|||
|
|||
- name: Local user has an SSH key |
|||
command: stat {{ my_ssh_key }} |
|||
changed_when: false |
|||
run_once: true |
|||
when: inventory_hostname in groups['manager'] |
|||
|
|||
- include: prepare_host.yml |
|||
when: inventory_hostname in groups['manager'] |
|||
|
|||
- include: lxc_prepare.yml |
|||
when: inventory_hostname in groups['manager'] |
|||
|
|||
- include: lxc_nodes.yml |
|||
when: inventory_hostname in groups['manager'] |
|||
|
|||
- name: container key is up-to-date locally |
|||
shell: ssh-keyscan {{ workers }} >> ~/.ssh/known_hosts |
|||
# with_items: |
|||
# - "10.0.3.100" |
|||
# - "10.0.3.101" |
|||
when: inventory_hostname in groups['manager'] |
|||
|
|||
- name: Install python on LXC container |
|||
raw: which python || (apt-get -y update && apt-get install -y python) |
|||
when: inventory_hostname in groups['workers'] |
|||
|
|||
- include: prepare_host.yml |
|||
when: inventory_hostname in groups['workers'] |
|||
|
|||
- include: swarm.yml |
|||
tags: swarm |
|||
|
|||
- setup: |
|||
tags: swarm, Dockerfile |
|||
|
|||
- include: Dockerfile.yml |
|||
when: inventory_hostname in groups['workers'] |
|||
tags: Dockerfile,swarm |
@ -0,0 +1,50 @@ |
|||
--- |
|||
- name: Install python-apt to use ansible apt module |
|||
shell: apt update && apt install -y python-apt |
|||
|
|||
- name: Ensure python and other dependencies are installed. |
|||
apt: |
|||
name: |
|||
- apt-transport-https |
|||
- ca-certificates |
|||
- gnupg |
|||
- python-pip |
|||
#- python-docker |
|||
state: present |
|||
|
|||
- name: pip install docker |
|||
pip: |
|||
name: docker |
|||
state: present |
|||
|
|||
- name: Add docker gpg key |
|||
#shell: wget https://download.docker.com/linux/debian/gpg -O - | apt-key add - |
|||
apt_key: |
|||
url: "https://download.docker.com/linux/debian/gpg" |
|||
state: present |
|||
|
|||
- name: Add docker stable repository for debian |
|||
apt_repository: |
|||
repo: "deb https://download.docker.com/linux/debian stretch stable" |
|||
state: present |
|||
|
|||
- name: Install lxc & docker |
|||
apt: |
|||
name: |
|||
- lxc |
|||
- docker |
|||
- docker-ce |
|||
- python-lxc |
|||
when: inventory_hostname in groups['manager'] |
|||
|
|||
- name: Install docker on worker nodes |
|||
apt: |
|||
name: |
|||
- docker-ce |
|||
when: inventory_hostname in groups['workers'] |
|||
|
|||
- name: Fix docker module missing issue |
|||
command: touch /.dockerenv |
|||
run_once: true |
|||
when: inventory_hostname in groups['workers'] |
|||
notify: Restart docker |
@ -0,0 +1,40 @@ |
|||
--- |
|||
- name: Prepare swarm manager |
|||
docker_swarm: |
|||
state: present |
|||
advertise_addr: "{{ interface }}" |
|||
when: inventory_hostname in groups['manager'] |
|||
|
|||
- name: Get the Manager join-token |
|||
shell: docker swarm join-token --quiet worker |
|||
register: worker_token |
|||
when: inventory_hostname in groups['manager'] |
|||
|
|||
- name: Prepare swarm workers |
|||
docker_swarm: |
|||
state: join |
|||
advertise_addr: "{{ interface }}" |
|||
join_token: "{{ hostvars[groups['manager'][0]]['worker_token']['stdout'] }}" |
|||
#remote_addrs: "{{ hostvars[groups['manager'][0]]['ansible_lxcbr0_ipv4.address'] }}" |
|||
remote_addrs: "10.0.3.1" |
|||
when: inventory_hostname in groups['workers'] |
|||
|
|||
- name: Prepare docker volumes |
|||
file: |
|||
path: /var/container_data/mysql |
|||
state: directory |
|||
mode: '0755' |
|||
when: inventory_hostname in groups['workers'] |
|||
|
|||
- name: Add docker labels for galera master and secondary nodes |
|||
shell: | |
|||
docker node update --label-add node1=true worker1 |
|||
docker node update --label-add node2=true worker2 |
|||
when: inventory_hostname in groups['workers'] |
|||
|
|||
#- name: Add docker labels for galera secondary nodes |
|||
# docker_node: |
|||
# labels: |
|||
# hostname: 'worker2' |
|||
# node2: true |
|||
# when: inventory_hostname in groups['workers'] |
@ -0,0 +1,10 @@ |
|||
FROM ubuntu:16.04 |
|||
RUN apt-get update |
|||
RUN apt-get install -y software-properties-common wget |
|||
RUN wget https://mariadb.org/mariadb_release_signing_key.asc -O - | apt-key add - |
|||
RUN add-apt-repository "deb [arch=amd64,arm64,i386,ppc64el] http://mirrors.coreix.net/mariadb/repo/10.4/ubuntu xenial main" |
|||
RUN apt-get update |
|||
RUN apt install -y rsync mariadb-server-10.4 galera-4 mariadb-client-10.4 |
|||
RUN systemctl unmask mariadb |
|||
COPY /galera.cnf /etc/mysql/conf.d/galera.cnf |
|||
ENTRYPOINT ["mysqld","{{ extra_docker_options }}"] |
@ -0,0 +1,20 @@ |
|||
[mysqld] |
|||
binlog_format=ROW |
|||
default-storage-engine=innodb |
|||
innodb_autoinc_lock_mode=2 |
|||
bind-address=0.0.0.0 |
|||
|
|||
# Galera Provider Configuration |
|||
wsrep_on=ON |
|||
wsrep_provider=/usr/lib/galera/libgalera_smm.so |
|||
|
|||
# Galera Cluster Configuration |
|||
wsrep_cluster_name="galera_cluster" |
|||
wsrep_cluster_address="gcomm://{% for host in groups['workers'] %} {{hostvars[host]['ansible_default_ipv4']['address']}} {% endfor %}" |
|||
|
|||
# Galera Synchronization Configuration |
|||
wsrep_sst_method=rsync |
|||
|
|||
# Galera Node Configuration |
|||
wsrep_node_address="{{ ansible_default_ipv4.address }}" |
|||
wsrep_node_name="{{ ansible_hostname }}" |
@ -0,0 +1,5 @@ |
|||
linux.kernel_modules= br_netfilter |
|||
lxc.network.type = veth |
|||
lxc.network.link = {{ interface }} |
|||
lxc.network.flags = up |
|||
lxc.network.hwaddr = 00:00:03:12:22:12 |
@ -0,0 +1,6 @@ |
|||
dhcp-host=swarm1,10.0.3.2 |
|||
dhcp-host=swarm2,10.0.3.3 |
|||
dhcp-host=swarm3,10.0.3.4 |
|||
dhcp-host=worker1,10.0.3.100 |
|||
dhcp-host=worker2,10.0.3.101 |
|||
dhcp-host=worker3,10.0.3.102 |
@ -0,0 +1,5 @@ |
|||
USE_LXC_BRIDGE=true |
|||
LXC_ADDR="10.0.3.1" #Address of lxcbr0 on the host |
|||
LXC_NETWORK="10.0.3.0/24" |
|||
LXC_DHCP_RANGE="10.0.3.2,10.0.3.254" |
|||
LXC_DHCP_CONFILE=/etc/lxc/dhcp.conf |
@ -0,0 +1,88 @@ |
|||
version: '3.2' |
|||
|
|||
services: |
|||
|
|||
db_cluster_node1: |
|||
|
|||
image: ubuntu:galera-node-worker1 |
|||
|
|||
# environment: |
|||
# - NODENAME={{.Node.Hostname}} |
|||
# - NODEID={{.Node.ID}} |
|||
# - SERVICEID={{.Service.ID}} |
|||
# - SERVICENAME={{.Service.Name}} |
|||
# - TASKID={{.Task.ID}} |
|||
# - TASKNAME={{.Task.Name}} |
|||
# - TASKREPID={{.Task.Slot}} |
|||
|
|||
volumes: |
|||
|
|||
- /var/container_data/mysql:/var/lib/mysql |
|||
|
|||
networks: |
|||
galera_net: |
|||
|
|||
deploy: |
|||
replicas: 1 |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
placement: |
|||
constraints: |
|||
- node.labels.node1 == true |
|||
- node.role == worker |
|||
#- node.group == galera |
|||
ports: |
|||
- mode: host |
|||
# target: 3306 |
|||
# published: 3306 |
|||
target: 4567 |
|||
published: 4567 |
|||
# target: 4568 |
|||
# published: 4568 |
|||
# target: 4568 |
|||
# published: 4568 |
|||
|
|||
#- "10.0.3.100:3306:3306" |
|||
#- "10.0.3.100:4567:4567" |
|||
#- "10.0.3.100:4568:4568" |
|||
#- "10.0.3.100:4444:4444" |
|||
|
|||
db_cluster_node2: |
|||
|
|||
image: ubuntu:galera-node-worker2 |
|||
|
|||
volumes: |
|||
|
|||
- /var/container_data/mysql:/var/lib/mysql |
|||
|
|||
networks: |
|||
galera_net: |
|||
|
|||
deploy: |
|||
replicas: 1 |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
placement: |
|||
constraints: |
|||
- node.labels.node2 == true |
|||
- node.role == worker |
|||
# - node.group == galera |
|||
depends_on: |
|||
- db_cluster_node1 |
|||
ports: |
|||
- mode: host |
|||
target: 4567 |
|||
published: 4567 |
|||
# - "10.0.3.101:3306:3306" |
|||
# - "10.0.3.101:4567:4567" |
|||
# - "10.0.3.101:4568:4568" |
|||
# - "10.0.3.101:4444:4444" |
|||
|
|||
|
|||
networks: |
|||
galera_net: |
|||
|
@ -0,0 +1 @@ |
|||
localhost |
@ -0,0 +1,5 @@ |
|||
--- |
|||
- hosts: localhost |
|||
remote_user: root |
|||
roles: |
|||
- roles/galera_swarm |
@ -0,0 +1,6 @@ |
|||
interface: lxcbr0 |
|||
extra_docker_options: "{{ ' --wsrep-new-cluster' if ansible_hostname == 'worker1' else '' }}" |
|||
workers: |
|||
- "10.0.3.100" |
|||
- "10.0.3.101" |
|||
# - "10.0.3.102" |
@ -0,0 +1,88 @@ |
|||
version: '3.2' |
|||
|
|||
services: |
|||
|
|||
db_cluster_node1: |
|||
|
|||
image: ubuntu:galera-node-worker1 |
|||
|
|||
# environment: |
|||
# - NODENAME={{.Node.Hostname}} |
|||
# - NODEID={{.Node.ID}} |
|||
# - SERVICEID={{.Service.ID}} |
|||
# - SERVICENAME={{.Service.Name}} |
|||
# - TASKID={{.Task.ID}} |
|||
# - TASKNAME={{.Task.Name}} |
|||
# - TASKREPID={{.Task.Slot}} |
|||
|
|||
volumes: |
|||
|
|||
- /var/container_data/mysql:/var/lib/mysql |
|||
|
|||
networks: |
|||
galera_net: |
|||
|
|||
deploy: |
|||
replicas: 1 |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
placement: |
|||
constraints: |
|||
- node.labels.node1 == true |
|||
- node.role == worker |
|||
#- node.group == galera |
|||
ports: |
|||
- mode: host |
|||
# target: 3306 |
|||
# published: 3306 |
|||
target: 4567 |
|||
published: 4567 |
|||
# target: 4568 |
|||
# published: 4568 |
|||
# target: 4568 |
|||
# published: 4568 |
|||
|
|||
#- "10.0.3.100:3306:3306" |
|||
#- "10.0.3.100:4567:4567" |
|||
#- "10.0.3.100:4568:4568" |
|||
#- "10.0.3.100:4444:4444" |
|||
|
|||
db_cluster_node2: |
|||
|
|||
image: ubuntu:galera-node-worker2 |
|||
|
|||
volumes: |
|||
|
|||
- /var/container_data/mysql:/var/lib/mysql |
|||
|
|||
networks: |
|||
galera_net: |
|||
|
|||
deploy: |
|||
replicas: 1 |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
placement: |
|||
constraints: |
|||
- node.labels.node2 == true |
|||
- node.role == worker |
|||
# - node.group == galera |
|||
depends_on: |
|||
- db_cluster_node1 |
|||
ports: |
|||
- mode: host |
|||
target: 4567 |
|||
published: 4567 |
|||
# - "10.0.3.101:3306:3306" |
|||
# - "10.0.3.101:4567:4567" |
|||
# - "10.0.3.101:4568:4568" |
|||
# - "10.0.3.101:4444:4444" |
|||
|
|||
|
|||
networks: |
|||
galera_net: |
|||
|
Loading…
Reference in new issue