-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-3-ct.yml
48 lines (46 loc) · 2.14 KB
/
create-3-ct.yml
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
--- # full playbook to create 3 CTs.
- hosts: project-init # contains only the hypervisor proxmox and the ansible master.
connection: ssh
gather_facts: yes
user: scotty # this is the operative ansible user
vars_files:
- init_vars.yml # contains the variables for building the CTs.
tasks:
- name: create containers 1 thru 3
proxmox:
state: present # only ensure they are there.
node: prox
api_user: scotty@pam # user specifically for this project
api_password: 3nterprise
api_host: prox
password: tester0 # this will be common on all 3 CTs.
hostname: "host{{ item }}"
# with_items:
# - 1
# - 2
# - 3
pool: project
ostemplate: 'local:vztmpl/centos-7-default_20160205_amd64.tar.xz'
netif: '{"net0":"name=eth0,gw=192.168.1.1,ip=192.168.1.6{{ item }}/24,bridge=vmbr0"}'
with_items:
- 1
- 2
- 3
disk: 2 # 2GB disk volume size
nameserver: 8.8.8.8 # the Google DNS
cpus: 1
memory: 512 # MB RAM
pubkey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQGD/I7IR6QqMHSmYys9QY621rKF10eh5FSycwrCGlKSq5wEMLMmMF0w56EzdJEJs7cvRG0Jdg359iL37Yfr3h3590kB45xrLmidAut4XCrU2trJFIEqjm9m4GJarQOCb4FbhRU44HjoLY4ZtcYkhAKy3oydlgYqUcg0BCV9xf16kj3vogytjOl7jmR6syJRJI1O44XHx+fN/WLqkHyJqxvEGiwTOzBDBvqi96nNJFYfl2fKWWJycfAKOb43zsR1PVHDNVP22JBk9dD8pjDabd/JE0b8HAJJT9FRUQn4iOU1d8sBvbqyNySkj5WHjoPjNeV63S7clj+/EV5n/BgK1UxNscotty@amobpc.adj.home'
when: ansible_hostname == "prox.adj.home"
# created 3 hosts, at 192.168.1.61-63/24
# now generate ansible-hosts file on ansible master, for the 3 containers.
# - name: generate ansible inventory of the above created LXC containers
# template:
# #ensures the inventory is created on this ansible master
# backup: yes # takes a backup of any existing.
# force: yes # replaces existing.
# state: present # ensures present
# src: templates/gen-hosts.j2
# dest: /home/scotty/ansible/atq-prj/hosts
# when: ansible_hostname == "ansible.adj.home"
# at this point the 3 containers and the hosts file including them, are ready.