Skip to content

Commit 13d2c05

Browse files
committed
progress on switching to docker in 11
1 parent 899fe00 commit 13d2c05

File tree

1 file changed

+76
-7
lines changed

1 file changed

+76
-7
lines changed

chapter_11_ansible.asciidoc

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,17 @@ so once you've set up your A-record,
207207
you can check its progress on a "propagation checking" service like this one:
208208
https://www.whatsmydns.net/#A/staging.ottg.co.uk.
209209

210-
I'm planning to host my staging server at 'staging.ottg.co.uk':
210+
I'm planning to host my staging server at _staging.ottg.co.uk_
211+
212+
=== Installing ansible
213+
214+
TODO:
215+
216+
https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html
217+
218+
suggests pipx. could also install it in the local virtualenv?
219+
may need to add docker-sdk
220+
211221

212222

213223
=== A first Cut of an Ansible Script
@@ -242,7 +252,6 @@ The "hate" part is that the actual syntax is surprisingly fiddly to get right:
242252
the difference between lists and key/value maps is subtle and I can never quite remember it honestly.]
243253
relationship with.
244254

245-
TODO: forget podman, just use docker.
246255

247256
[role="sourcecode"]
248257
.infra/ansible-provision.yaml (ch11l001)
@@ -289,6 +298,7 @@ TODO: forget podman, just use docker.
289298
state: started
290299
image: busybox
291300
command: echo hello world
301+
become: true
292302
----
293303
====
294304

@@ -301,28 +311,87 @@ TODO: forget podman, just use docker.
301311
The next few use the `builtin.apt` module which provides
302312
a wrapper around the `apt` Debian & Ubuntu package management tool.
303313

304-
<3> Each module then provides a bunch of parameters which control
305-
how it works. Here we specify the `name` of the package we want to install ("docker")
306-
and tell it update its cache first, which is required on a fresh server.
314+
<3> Each module then provides a bunch of parameters which control how it works.
315+
Here we specify the `name` of the package we want to install ("docker")
316+
and tell it update its cache first, which is required on a fresh server.
307317

308318
Most ansible modules have pretty good documentation,
309319
check out the `builtin.apt` one for example.
310-
I often skip to the https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html#examples[Examples section].
320+
I often skip to the
321+
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html#examples[Examples section].
322+
311323

312324
[subs="specialcharacters,quotes"]
313325

314326
----
315327
$ *ansible-playbook --user=elspeth -i 192.168.56.10, infra/ansible-provision.yaml -vv*
328+
PLAYBOOK: ansible-provision.yaml **********************************************
329+
1 plays in infra/ansible-provision.yaml
330+
331+
PLAY [all] ********************************************************************
332+
333+
TASK [Gathering Facts] ********************************************************
334+
task path: ...goat-book/infra/ansible-provision.yaml:2
335+
ok: [192.168.56.10]
336+
337+
TASK [Add Docker GPG apt Key] *************************************************
338+
task path: ...goat-book/infra/ansible-provision.yaml:9
339+
changed: [192.168.56.10] => {"after": ["8D81803C0EBFCD88", "7EA0A9C3F273FCD8", "D94AA3F0EFE21092", "871920D1991BC93C"], "before": ["D94AA3F0EFE21092", "871920D1991BC93C"], "changed": true, "fp": "8D81803C0EBFCD88", "id": "8D81803C0EBFCD88", "key_id": "8D81803C0EBFCD88", "short_id": "0EBFCD88"}
340+
341+
TASK [Add Docker Repository] **************************************************
342+
task path: ...goat-book/infra/ansible-provision.yaml:14
343+
changed: [192.168.56.10] => {"changed": true, "repo": "deb https://download.docker.com/linux/ubuntu jammy stable", "sources_added": ["/etc/apt/sources.list.d/download_docker_com_linux_ubuntu.list"], "sources_removed": [], "state": "present"}
344+
345+
TASK [Update apt and install docker-ce] ***************************************
346+
task path: ...goat-book/infra/ansible-provision.yaml:19
347+
changed: [192.168.56.10] => {"cache_update_time": [...]
348+
changed: [192.168.56.10] => {"cache_update_time": 1706583891, "cache_updated":
349+
true, "changed": true, "stderr": "", "stderr_lines": [], "stdout": "Reading
350+
package lists...\nBuilding dependency tree...\nReading state
351+
information...\nThe following additional packages will be installed:\n
352+
containerd.io docker-buildx-plugin docker-ce-cli docker-ce-rootless-extras\n
353+
[...]
354+
TASK [Add our user to Docker allowed users] ***********************************
355+
changed: [192.168.56.10] => {"append": true, "changed": true, "comment": "",
356+
"group": 1001, "groups": "docker", "home": "/home/elspeth", "move_home": false,
357+
"name": "elspeth", "shell": "/bin/bash", "state": "present", "uid": 1001}
358+
TASK [Run test container] *****************************************************
359+
task path: ...goat-book/infra/ansible-provision.yaml:31
360+
changed: [192.168.56.10] => {"changed": true, "container": {"AppArmorProfile":
361+
"docker-default", "Args": ["hello", "world"], "Config": {"AttachStderr": true,
362+
"AttachStdin": false, "AttachStdout": true, "Cmd": ["echo", "hello", "world"],
363+
[...]
364+
365+
PLAY RECAP ***********************************************************
366+
192.168.56.10 : ok=6 changed=6 unreachable=0 failed=0
367+
skipped=0 rescued=0 ignored=0
316368
----
317369

318-
TODO: show ansible output.
319370
TODO: stop using local ip
320371

321372

373+
////
374+
375+
this goes wrong because groups don't work immediately:
376+
377+
TASK [Run test container] *****************************************************
378+
fatal: [192.168.56.10]: FAILED! => {"changed": false, "msg": "Error connecting:
379+
Error while fetching server API version: ('Connection aborted.',
380+
PermissionError(13, 'Permission denied'))"}
381+
382+
waiting a few minutes fixes it
383+
384+
for now i'll just put become:true
385+
386+
387+
////
388+
389+
322390
=== SSHing Into the Server and Viewing Container Logs
323391

324392
Now ssh into the server, check it worked
325393

394+
TODO: forget podman, just use docker.
326395

327396
[role="server-commands"]
328397
[subs="specialcharacters,quotes"]

0 commit comments

Comments
 (0)