Browse Source

Dhcp changes

dev
root 4 years ago
parent
commit
875829d4be
  1. 2
      ansible_provisioning.sh
  2. 2
      clean.sh
  3. 2
      environment_bnode_script.sh
  4. 2
      inventory/hosts
  5. 4
      roles/lxc_swarm/tasks/lxc_nodes.yml
  6. 4
      roles/lxc_swarm/tasks/main.yml
  7. 13
      roles/lxc_swarm/templates/Dockerfile.j2
  8. 5
      roles/lxc_swarm/templates/Mariadb_Dockerfile.j2
  9. 4
      roles/lxc_swarm/templates/lxc_dhcp.conf.j2
  10. 2
      roles/lxc_swarm/vars/main.yml

2
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

2
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

2
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

2
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

4
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

4
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

13
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 }}"]

5
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

4
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

2
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"

Loading…
Cancel
Save