refactor ansible role for swarm runner

This commit is contained in:
fl0ppy-d1sk 2024-03-06 18:45:36 +01:00
parent 6a428c3309
commit fe844b0a38
No known key found for this signature in database
GPG key ID: 93EE47CC3D061500
20 changed files with 20 additions and 88 deletions

View file

@ -38,7 +38,7 @@ jobs:
run: pip install --no-cache-dir --require-hashes -r misc/requirements-ansible.txt
if: inputs.TYPE != 'k8s'
- name: Install ansible libs
run: ansible-galaxy install --timeout 120 monolithprojects.github_actions_runner,1.18.1 && ansible-galaxy collection install --timeout 120 community.general && ansible-galaxy collection install --timeout 120 community.docker
run: ansible-galaxy install --timeout 120 monolithprojects.github_actions_runner,1.19.0 && ansible-galaxy collection install --timeout 120 community.general && ansible-galaxy collection install --timeout 120 community.docker
if: inputs.TYPE != 'k8s'
# Create infra
- run: ./tests/create.sh ${{ inputs.TYPE }}

View file

@ -274,7 +274,7 @@
This website is protected with
<a
class="underline hover:italic hover:brightness-90 transition"
href="https://www.bunkerweb.io/?utm_campaign=self&utm_source=bwerror"
href="https://www.bunkerweb.io/?utm_campaign=self&utm_source=bwantibot"
target="_blank"
>BunkerWeb</a
>

View file

@ -595,7 +595,7 @@
This website is protected with
<a
class="underline hover:italic hover:brightness-90 transition"
href="https://github.com/bunkerity/bunkerweb"
href="https://www.bunkerweb.io/?utm_campaign=self&utm_source=bwerror"
target="_blank"
>BunkerWeb</a
>

View file

@ -1 +0,0 @@
network: {config: disabled}

View file

@ -1,5 +0,0 @@
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.ens3.disable_ipv6 = 1
net.ipv6.conf.ens4.disable_ipv6 = 1

View file

@ -1,8 +0,0 @@
---
- name: Restart networking
service:
name: networking
state: restarted
- name: Reload sysctl
shell: sysctl -p -f /etc/sysctl.d/70-disable-ipv6.conf

View file

@ -1,5 +1,4 @@
---
#- include_tasks: network.yml
- include_tasks: user.yml
- include_tasks: apt.yml
- include_tasks: hostname.yml

View file

@ -1,28 +0,0 @@
---
- name: Update /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
copy:
src: 99-disable-network-config.cfg
dest: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
owner: root
group: root
mode: "0644"
- name: Update /etc/network/interfaces.d/50-cloud-init
template:
src: 50-cloud-init
dest: /etc/network/interfaces.d/50-cloud-init
owner: root
group: root
mode: "0644"
notify:
- Restart networking
- name: Update /etc/sysctl.d/70-disable-ipv6.conf
copy:
src: ipv6.conf
dest: /etc/sysctl.d/70-disable-ipv6.conf
owner: root
group: root
mode: "0644"
notify:
- Reload sysctl

View file

@ -1,13 +0,0 @@
auto lo
iface lo inet loopback
dns-nameservers 213.186.33.99 0.0.0.0
auto ens3
iface ens3 inet dhcp
accept_ra 0
mtu 1500
auto ens3:0
iface ens3:0 inet static
address {{ failover_ip }}
netmask 255.255.255.255

View file

@ -28,8 +28,8 @@
update_cache: yes
state: present
- name: Install /usr/local/bin/docker-compose
shell: curl -L https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
# - name: Install /usr/local/bin/docker-compose
# shell: curl -L https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
- name: Add user to docker group
user:

View file

@ -1,5 +0,0 @@
---
- name: Restart networking
service:
name: networking
state: restarted

View file

@ -1,2 +0,0 @@
---
- include_tasks: network.yml

View file

@ -1,10 +0,0 @@
---
- name: Update /etc/network/interfaces.d/60-ens5-vpc
template:
src: 60-ens5-vpc
dest: /etc/network/interfaces.d/60-ens5-vpc
owner: root
group: root
mode: "0644"
notify:
- Restart networking

View file

@ -1,4 +0,0 @@
auto ens5
allow-hotplug ens5
iface ens5 inet static
address {{ local_ip }}/24

View file

@ -8,5 +8,5 @@
volumes:
- /etc/docker/registry:/var/lib/registry
published_ports:
- "192.168.42.100:5000:5000"
- "{{ local_ip }}:5000:5000"
when: inventory_hostname == groups['managers'][0]

View file

@ -1,3 +1,3 @@
{
"insecure-registries": ["192.168.42.100:5000"]
"insecure-registries": ["manager:5000"]
}

View file

@ -29,6 +29,15 @@
# executable: pip3
# extra_args:
- name: Add IP address of all hosts to all hosts
lineinfile:
dest: /etc/hosts
regexp: '.*{{ item }}$'
line: "{{ hostvars[item].local_ip }} {{item}}"
state: present
when: hostvars[item].local_ip is defined
with_items: "{{ groups.all }}"
- name: Init Docker Swarm
community.docker.docker_swarm:
advertise_addr: "{{ local_ip }}"

View file

@ -15,7 +15,6 @@
roles:
- common
- docker
- private_net
- hosts: all
name: Setup swarm

View file

@ -39,6 +39,7 @@ resource "scaleway_instance_server" "instances" {
resource "local_sensitive_file" "ansible_inventory" {
content = templatefile("templates/swarm_inventory.tftpl", {
public_ips = var.swarm_ips
local_ips = scaleway_instance_server.instances.*.private_ip
})
filename = "/tmp/swarm_inventory"
}

View file

@ -1,6 +1,6 @@
[managers]
manager ansible_host=${public_ips[0]} ansible_user=root local_ip=192.168.42.100
manager ansible_host=${public_ips[0]} ansible_user=root local_ip=${local_ips[0]}
[workers]
worker1 ansible_host=${public_ips[1]} ansible_user=root local_ip=192.168.42.101
worker2 ansible_host=${public_ips[2]} ansible_user=root local_ip=192.168.42.102
worker1 ansible_host=${public_ips[1]} ansible_user=root local_ip=${local_ips[1]}
worker2 ansible_host=${public_ips[2]} ansible_user=root local_ip=${local_ips[2]}