-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplanetexpress_setup.yml
More file actions
75 lines (65 loc) · 1.79 KB
/
planetexpress_setup.yml
File metadata and controls
75 lines (65 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
- name: "Teardown/Rebuild Containers"
hosts: localhost
connection: local
gather_facts: no
become: yes
vars:
images:
- host: bender
ip: 10.10.2.3
- host: fry
ip: 10.10.2.4
- host: zoidberg
ip: 10.10.2.5
- host: farnsworth
ip: 10.10.2.6
tasks:
- name: Install docker module
pip:
name: docker
- name: Create docker network
community.docker.docker_network:
name: ansible-net
driver_options: com.docker.network.driver.mtu=1450
ipam_config:
- subnet: 10.10.2.0/24
- name: Load PlanetExpress images
community.docker.docker_image:
name: "ssh-{{item.host }}"
load_path: "/home/student/.config/dockerfiles/ansible/ssh-{{ item.host }}.tar"
source: load
loop: "{{ images }}"
- name: Remove old containers
community.docker.docker_container:
name: "{{ item }}"
state: absent
container_default_behavior: compatibility
loop: ["john","paul","george","stuart","pete","ringo","indy","bender","fry","zoidberg","farnsworth"]
- name: Create PlanetExpress Containers
community.docker.docker_container:
name: "{{ item.host }}"
hostname: "{{ item.host }}"
detach: yes
image: "ssh-{{ item.host }}"
container_default_behavior: compatibility
network_mode: ansible-net
networks:
- ipv4_address: "{{ item.ip }}"
name: ansible-net
loop: "{{ images }}"
- name: "Copy Public Keys"
hosts: planetexpress,!farnsworth
connection: ssh
gather_facts: no
become: yes
vars:
ansible_ssh_pass: alta3
tasks:
- name: Set authorized key taken from file
authorized_key:
user: "{{ ansible_user }}"
state: present
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
tags:
- keys