This repository has been archived on 2023-12-26. You can view files and clone it, but cannot push or open issues or pull requests.
shoarma/ansible/playbooks/setup.yml

73 lines
1.6 KiB
YAML
Raw Normal View History

2023-05-02 09:51:22 +00:00
---
- name: Wait for Cloud-init to finish
hosts: manager, workers
2023-05-02 09:51:22 +00:00
gather_facts: no
roles:
- cloudinit_wait
- name: Initialize Docker Swarm nodes
hosts: manager, workers
2023-05-02 09:51:22 +00:00
pre_tasks:
- name: Delete externally managed environment file
shell:
cmd: "rm /usr/lib/python*/EXTERNALLY-MANAGED"
register: rm
changed_when: "rm.rc == 0"
failed_when: "false"
roles:
- setup_apt
2023-08-22 20:53:40 +00:00
post_tasks:
- name: Install Docker
include_role:
name: docker
vars:
docker_daemon_config:
log-driver: fluentd
log-opts:
fluentd-address: "localhost:22222"
tag: "docker.{{ '{{' }}.Name{{ '}}' }}"
2023-05-02 09:51:22 +00:00
- name: Setup Docker Swarm manager
hosts: manager
tasks:
- name: Install pip packages
pip:
name:
- jsondiff
- pyyaml
- name: Create Docker Swarm
docker_swarm:
- name: Get Docker Swarm manager info
docker_swarm_info:
nodes: yes
nodes_filters:
name: manager
register: swarm_info
- hosts: workers
tasks:
- name: Join Docker Swarm
docker_swarm:
state: join
join_token: "{{ hostvars.manager.swarm_info.swarm_facts.JoinTokens.Worker }}"
remote_addrs:
- "{{ hostvars.manager.ansible_default_ipv4.address }}"
- hosts: manager
tasks:
- name: Add concourse to authorized keys
authorized_key:
user: root
key: "{{ concourse_public_key }}"
2023-08-01 14:24:00 +00:00
- hosts: manager, workers
tasks:
- name: Increase vm.max_map_count
sysctl:
name: vm.max_map_count
value: 262144