48 lines
1.3 KiB
YAML
48 lines
1.3 KiB
YAML
---
|
|
- name: configure worker for docker swarm
|
|
become: yes
|
|
hosts: new
|
|
# add var file
|
|
vars_files:
|
|
- "var/swarm.yml"
|
|
- "var/hosts.yml"
|
|
- "var/registry.yml"
|
|
tasks:
|
|
- name: nfs common
|
|
when: inventory_hostname in groups['workers']
|
|
apt:
|
|
name: nfs-common
|
|
state: present
|
|
update_cache: yes
|
|
|
|
- name: login docker
|
|
become: yes
|
|
become_user: dockerman
|
|
shell: docker login -u {{ registry_user }} -p {{ registry_password }} {{ registry_url }}
|
|
|
|
- name: add enviroments to all servers
|
|
shell: |
|
|
echo "export ADMIN_USER=nerdguy" >> /etc/environment
|
|
echo "export ADMIN_PASSWORD=RbBmIu1LCgIqKcMmopc1Ie21+1OKsX1ktNCAeiViNIb6HAKkzjJ+GhZlLysItwgm" >> /etc/environment
|
|
|
|
- name: join node in swarm as worker
|
|
shell: docker swarm join --token {{ worker_token }} {{ item.local }}:2377
|
|
with_items:
|
|
- "{{ supermaster }}"
|
|
ignore_errors: yes
|
|
|
|
- name: create /volume
|
|
shell: mkdir -p /volume
|
|
|
|
- name: mount nfs
|
|
shell: mount {{ item.local }}:/volume /volume
|
|
with_items:
|
|
- "{{ masters }}"
|
|
|
|
|
|
- name: mount nfs /etc/fstab
|
|
shell: echo "{{ item.local }}:/volume /volume nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0" >> /etc/fstab
|
|
with_items:
|
|
- "{{ masters }}"
|
|
|