-
Notifications
You must be signed in to change notification settings - Fork 0
/
vagrant.yaml
144 lines (125 loc) · 3.77 KB
/
vagrant.yaml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
- hosts: all
become: yes
vars:
user: vagrant
group: vagrant
lxd_version: "4.0/stable"
juju_version: "2.8/stable"
charm_version: "stable"
charmcraft_version: "1.x/stable"
tasks:
# - name: Set max map count
# sysctl:
# name: vm.max_map_count
# value: '262144'
# sysctl_set: yes
# reload: yes
- name: Install packages
apt:
name:
- "zfsutils-linux"
- "bash-completion"
- "python3"
- "overlayroot"
- "libssl-dev"
- "libffi-dev"
state: latest
- name: Add the overlay module
modprobe:
name: overlay
state: present
- name: "Install lxd {{ lxd_version }} snap"
command: "snap install lxd --channel={{ lxd_version }}"
args:
creates: /snap/bin/lxd
- name: "Install juju {{ juju_version }} snap"
command: "snap install juju --classic --channel={{ juju_version }}"
args:
creates: /snap/bin/juju
- name: Run juju to generate juju dir
command: /snap/bin/juju
become_user: "{{ user }}"
args:
creates: ~/.local/share/juju
- name: Setup lxd
command: "{{ item }}"
with_items:
- lxd init --auto --storage-backend zfs --storage-create-loop 30 --storage-pool lxd
#- lxd init --auto --storage-backend btrfs --storage-create-loop 30 --storage-pool lxd
- lxc network set lxdbr0 ipv6.address none
ignore_errors: yes
- name: Bootstrap juju controller
command: juju bootstrap localhost lxd
become: yes
become_user: vagrant
ignore_errors: yes
async: 7200
poll: 0
register: juju_bootstrap
- name: Install packages
apt:
name:
- "apt-cacher-ng"
- "python3-apt"
- "python3-pip"
- "python3-testresources"
state: latest
- name: Add `watch-juju` alias and snap path to .bashrc
blockinfile:
path: "/home/{{ user }}/.bashrc"
content: |
# Add alias for easy watching of juju status
alias watch-juju='watch --color -n1 juju status --color'
# Add snaps to path
export PATH=/snap/bin:$PATH
- name: Configure apt-cacher-ng for https
lineinfile:
path: /etc/apt-cacher-ng/acng.conf
line: 'PassThroughPattern: .*'
- name: Restart apt-cacher-ng
service:
name: apt-cacher-ng
state: restarted
- name: Add apt proxy to juju config
blockinfile:
path: "/home/{{ user }}/.local/share/juju/clouds.yaml"
owner: "{{ user }}"
group: "{{ group }}"
mode: 0600
create: yes
content: |
clouds:
lxd:
type: lxd
config:
apt-http-proxy: http://{{ ansible_default_ipv4.address }}:3142
apt-https-proxy: http://{{ ansible_default_ipv4.address }}:3142
enable-os-upgrade: false
- name: Upgrade pip
become: false
pip:
name: pip
executable: pip3
extra_args: --upgrade --user
# version: '19.3.1' # xenial
- name: Install jujuna
become: false
pip:
name: ["jujuna", "tox"]
executable: pip3
extra_args: --user
ignore_errors: yes
- name: Install charm
command: "snap install charm --classic --channel={{ charm_version }}"
- name: Install charmcraft
command: "snap install charmcraft --classic --channel={{ charmcraft_version }}"
- name: Check on an async juju bootstrap task
async_status:
jid: "{{ juju_bootstrap.ansible_job_id }}"
become: yes
become_user: vagrant
ignore_errors: yes
register: job_result
until: job_result.finished
delay: 10
retries: 720