From 875829d4be6d6627cf4a9777307e51324c69b6a6 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 13 Jun 2020 11:50:40 +0000 Subject: [PATCH] Dhcp changes --- ansible_provisioning.sh | 2 +- clean.sh | 2 +- environment_bnode_script.sh | 2 +- inventory/hosts | 2 +- roles/lxc_swarm/tasks/lxc_nodes.yml | 4 ++-- roles/lxc_swarm/tasks/main.yml | 4 ++++ roles/lxc_swarm/templates/Dockerfile.j2 | 13 +++++++++++++ roles/lxc_swarm/templates/Mariadb_Dockerfile.j2 | 5 +++++ roles/lxc_swarm/templates/lxc_dhcp.conf.j2 | 4 ++-- roles/lxc_swarm/vars/main.yml | 2 +- 10 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 roles/lxc_swarm/templates/Dockerfile.j2 create mode 100644 roles/lxc_swarm/templates/Mariadb_Dockerfile.j2 diff --git a/ansible_provisioning.sh b/ansible_provisioning.sh index 44c33c0..8ba2987 100755 --- a/ansible_provisioning.sh +++ b/ansible_provisioning.sh @@ -1,4 +1,4 @@ #!/bin/bash [ `id -u` -ne 0 ] && exit 1 test -f /root/.ssh/id_rsa.pub || ssh-keygen -t rsa -b 4096 -N '' -f /root/.ssh/id_rsa -ansible-playbook -i inventory/hosts --skip-tags swarm --diff -v swarm-galera.yml +ansible-playbook -i inventory/hosts --tags configuration --diff -v swarm-galera.yml diff --git a/clean.sh b/clean.sh index 6b042c7..155aa4c 100755 --- a/clean.sh +++ b/clean.sh @@ -1,5 +1,5 @@ #!/bin/bash docker stack rm stack lxc-stop --name worker1; lxc-stop --name worker2 -docker node rm worker1; docker node rm worker2 rm -rf /var/lib/lxc/worker* +docker node rm worker1; docker node rm worker2 diff --git a/environment_bnode_script.sh b/environment_bnode_script.sh index 903ae2d..059860c 100755 --- a/environment_bnode_script.sh +++ b/environment_bnode_script.sh @@ -4,5 +4,5 @@ mcontainer_addr=$(ssh root@10.0.3.100 "docker ps|xargs -n1|grep -i NAMES -A 1|ta MASTER_ADDR=$(ssh -t root@10.0.3.100 "docker exec -it $mcontainer_addr ip a s|grep -i 10.0|head -1 2>/dev/null" 2>&1 |grep inet|awk '{print $2}'|cut -d "/" -f 1) [ -z $MASTER_ADDR ] && echo "Node 1 hasn't yet been initialized" && exit 1 env MASTER_ADDR="${MASTER_ADDR}" docker stack deploy -c stack.yaml stack -env MASTER_ADDR="${MASTER_ADDR}" docker service scale stack_bnode=1 +#env MASTER_ADDR="${MASTER_ADDR}" docker service scale stack_bnode=1 diff --git a/inventory/hosts b/inventory/hosts index c324184..7b6dd93 100644 --- a/inventory/hosts +++ b/inventory/hosts @@ -3,6 +3,6 @@ [workers] 10.0.3.100 ansible_ssh_user=root -10.0.3.101 ansible_ssh_user=root +10.0.3.128 ansible_ssh_user=root #For more workers add here the extra configuration #10.0.3.102 ansible_ssh_user=root diff --git a/roles/lxc_swarm/tasks/lxc_nodes.yml b/roles/lxc_swarm/tasks/lxc_nodes.yml index ddcae9c..bbdef25 100644 --- a/roles/lxc_swarm/tasks/lxc_nodes.yml +++ b/roles/lxc_swarm/tasks/lxc_nodes.yml @@ -33,14 +33,14 @@ shell: ssh-keygen -f /root/.ssh/known_hosts -R {{ item }} with_items: - "10.0.3.100" - - "10.0.3.101" + - "10.0.3.128" when: inventory_hostname in groups['manager'] - name: Ensure container key is up-to-date locally shell: ssh-keyscan -T 15 {{ item }} >> /root/.ssh/known_hosts with_items: - "10.0.3.100" - - "10.0.3.101" + - "10.0.3.128" when: inventory_hostname in groups['manager'] - name: Install python on LXC container diff --git a/roles/lxc_swarm/tasks/main.yml b/roles/lxc_swarm/tasks/main.yml index dbaaf75..17ee196 100644 --- a/roles/lxc_swarm/tasks/main.yml +++ b/roles/lxc_swarm/tasks/main.yml @@ -1,14 +1,18 @@ --- # tasks file for roles/galera_swarm - include: prepare_manager_host.yml + tags: configuration when: inventory_hostname in groups['manager'] - include: lxc_prepare.yml + tags: configuration when: inventory_hostname in groups['manager'] - include: lxc_nodes.yml + tags: configuration - include: prepare_worker_host.yml + tags: configuration when: inventory_hostname in groups['workers'] - include: swarm.yml diff --git a/roles/lxc_swarm/templates/Dockerfile.j2 b/roles/lxc_swarm/templates/Dockerfile.j2 new file mode 100644 index 0000000..ad0bb59 --- /dev/null +++ b/roles/lxc_swarm/templates/Dockerfile.j2 @@ -0,0 +1,13 @@ +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 +COPY galera.cnf /etc/mysql/conf.d/galera.cnf +#RUN echo "wsrep_node_address=`ip a s eth0|grep inet|head -1|awk '{print $2}'|cut -d "/" -f 1`" >> /etc/mysql/conf.d/galera.cnf +RUN chown -R mysql:mysql /etc/mysql +RUN chmod -R go-w /etc/mysql +EXPOSE 3306 4444 4567 4568 +#ENTRYPOINT ["mysqld","{{ extra_docker_options }}"] diff --git a/roles/lxc_swarm/templates/Mariadb_Dockerfile.j2 b/roles/lxc_swarm/templates/Mariadb_Dockerfile.j2 new file mode 100644 index 0000000..139df1f --- /dev/null +++ b/roles/lxc_swarm/templates/Mariadb_Dockerfile.j2 @@ -0,0 +1,5 @@ +FROM mariadb:10.4 +COPY galera.cnf /etc/mysql/conf.d/my.cnf +RUN chown -R mysql:mysql /etc/mysql +RUN chmod -R go-w /etc/mysql +EXPOSE 3306 4444 4567 4568 diff --git a/roles/lxc_swarm/templates/lxc_dhcp.conf.j2 b/roles/lxc_swarm/templates/lxc_dhcp.conf.j2 index 6f7c85f..3f36549 100644 --- a/roles/lxc_swarm/templates/lxc_dhcp.conf.j2 +++ b/roles/lxc_swarm/templates/lxc_dhcp.conf.j2 @@ -2,5 +2,5 @@ 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 +dhcp-host=worker2,10.0.3.128 +#dhcp-host=worker3,10.0.3.156 diff --git a/roles/lxc_swarm/vars/main.yml b/roles/lxc_swarm/vars/main.yml index d3749a8..ba4a57f 100644 --- a/roles/lxc_swarm/vars/main.yml +++ b/roles/lxc_swarm/vars/main.yml @@ -2,7 +2,7 @@ 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.128" # - "10.0.3.102" nodes: - "node1"