@@ -69,6 +69,8 @@ just pick any old registrar and buy a cheap one--it
69
69
should only cost you $5 or so, and you can even find free ones.
70
70
I promise seeing your site on a "real" website will be a thrill.
71
71
72
+ // DAVID: just wondering if it's worth giving them the option to cheat and
73
+ // specify a domain name in a hosts file?
72
74
73
75
74
76
=== Manually Provisioning a Server to Host Our Site
@@ -187,6 +189,7 @@ wild place!
187
189
((("Platform-As-A-Service (PaaS)")))
188
190
*******************************************************************************
189
191
192
+ // DAVID: looks like plusbryan.com has changed hands.
190
193
////
191
194
192
195
TODO: good advice but not quite sure it's phrased quite right for the new version of the chapter.
@@ -261,7 +264,7 @@ rather than specifying a procedural series of steps to be followed one by one.
261
264
262
265
==== Installing Ansible
263
266
264
- Take a look at the https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html [documentation] for instructions on how to install Ansible/
267
+ Take a look at the https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html [documentation] for instructions on how to install Ansible.
265
268
// RITA: Please anchor all URLs to descriptive text.
266
269
267
270
The simplest thing to do is to install Ansible into the virtualenv
@@ -293,9 +296,11 @@ The "hate" part is that the actual syntax is surprisingly fiddly to get right:
293
296
the difference between lists and key/value maps is subtle and I can never quite remember it honestly.]
294
297
for.
295
298
299
+ // DAVID: I didn't know if this was an example or a file to create.
300
+ // I think it's the latter, it would be good to make that clear.
296
301
297
302
[role="sourcecode"]
298
- .infra/ansible-provision.yaml (ch11l001)
303
+ .infra/ansible-provision.yaml (ch11l001)
299
304
====
300
305
[source,yaml]
301
306
----
@@ -342,7 +347,7 @@ I often skip to the
342
347
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html#examples[Examples section].
343
348
344
349
// RITA: Please add a sentence or two to introduce the following code block.
345
-
350
+ // DAVID: +1, this wrong footed me.
346
351
[subs="specialcharacters,quotes"]
347
352
----
348
353
$ *ansible-playbook --user=elspeth -i staging.ottg.co.uk, infra/ansible-provision.yaml -vv*
@@ -388,6 +393,25 @@ PLAY RECAP ********************************************************************
388
393
staging.ottg.co.uk : ok=3 changed=2 unreachable=0 failed=0
389
394
skipped=0 rescued=0 ignored=0
390
395
----
396
+ // DAVID: rather than having to edit the username and domains each time,
397
+ // what about getting the reader to set them as environment variables at the beginning of the chapter?
398
+
399
+ // DAVID: I got ansible-playbook: error: unrecognized arguments: --vv
400
+ // ansible==9.4.0
401
+ // ansible-core==2.16.6
402
+ // Changed it to -v
403
+
404
+ // DAVID: Then I got:
405
+ // FAILED! => {"msg": "Missing sudo password"}
406
+ // I don't have much context about what's going on here, e.g. there are several machines
407
+ // this could be interacting with - my local, a container in my local,
408
+ // the remote, a container in remote. Or maybe I'm contacting the wrong remote computer.
409
+ // So not that clear how to troubleshoot.
410
+ // (I did set up a sudo user on the server as per your github guide.)
411
+ // Maybe giving a bit more explanation on what this command is doing would help.
412
+ // UPDATE: got this working with `--ask-become-pass` - we discussed this in person.
413
+ // But, as discussed, it is annoying to have to keep typing your password in when we could
414
+ // authenticate with the ssh key. Could we change this?
391
415
392
416
I don't know about you, but whenever I make a terminal spew out a stream
393
417
of output, I like to make little _brrp brrp brrp_ noises, a bit like the
@@ -425,6 +449,11 @@ elspeth@server:$ *docker logs testcontainer*
425
449
hello world
426
450
----
427
451
452
+ // DAVID: Got
453
+ // permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
454
+ // Sudo fixed it.
455
+ // Update: I think better to add my user to the docker group before this point.
456
+
428
457
TIP: Look out for that `elspeth@server`
429
458
in the command-line listings in this chapter.
430
459
It indicates commands that must be run on the server,
@@ -570,6 +599,13 @@ false, "AttachStdout": true, "Cmd": ["gunicorn", "--bind", ":8888",
570
599
[...]
571
600
----
572
601
602
+ // DAVID: I got error during the 'Export container image locally' step.
603
+ // FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version:
604
+ // ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))"}
605
+ // Update: I fixed it by doing ``sudo usermod -aG docker ${USER}`` on the remote machine.
606
+ // Maybe worth getting them to shell in and run `docker run hello-world` to
607
+ // check their user has permission.
608
+ // DAVID: by the way it's getting annoying having to type my sudo password in all the time.
573
609
574
610
For completeness, let's also add a step to explicitly build the image locally.
575
611
This means we don't have a dependency on having run `docker build` locally.
@@ -621,6 +657,10 @@ PORTS NAMES
621
657
3a2e600fbe77 busybox "echo hello world" 2 days ago Exited (0) 10
622
658
minutes ago testcontainer
623
659
660
+ // DAVID: I can also see superlists listed (though exited).
661
+ // In any event, feels like needs a bit more explanation of
662
+ // your thought process?
663
+
624
664
elspeth@server:$ *docker logs testcontainer*
625
665
[2024-02-26 22:19:15 +0000] [1] [INFO] Starting gunicorn 21.2.0
626
666
[2024-02-26 22:19:15 +0000] [1] [INFO] Listening at: http://0.0.0.0:8888 (1)
@@ -665,6 +705,9 @@ It's a common tool in Ansible scripts, and the syntax is very similar to Django'
665
705
666
706
Here's what our template for the env file will look like:
667
707
708
+ // DAVID: These days wouldn't it be called env.jinja as
709
+ // per https://jinja.palletsprojects.com/en/3.1.x/templates/#template-file-extension?
710
+
668
711
[role="sourcecode"]
669
712
.infra/env.j2 (ch11l004)
670
713
====
@@ -799,9 +842,14 @@ staging.ottg.co.uk : ok=8 changed=6 unreachable=0 failed=0
799
842
skipped=0 rescued=0 ignored=0
800
843
----
801
844
802
- Looks good! What do our tests think?
845
+ // DAVID: suggest you get us to we shell in and see the env file there.
803
846
847
+ Looks good! What do our tests think?
804
848
849
+ // DAVID: this command assumes we'll be in a different working directory
850
+ // to the previous command.
851
+ // Also... I originally just pasted this as-is, which contacted YOUR server. Another
852
+ // reason to get them to set environment variables at the start of the chapter.
805
853
==== More debugging
806
854
807
855
We run our tests as usual and run into a new problem:
@@ -814,6 +862,9 @@ selenium.common.exceptions.WebDriverException: Message: Reached error page:
814
862
about:neterror?e=connectionFailure&u=http%3A//staging.ottg.co.uk/[...]
815
863
----
816
864
865
+ // DAVID: I got selenium.common.exceptions.NoSuchElementException
866
+ // On the server, I get 'Host not found'.
867
+
817
868
That `neterror` makes me think it's another networking problem.
818
869
Let's try `curl` locally:
819
870
@@ -826,6 +877,8 @@ curl: (7) Failed to connect to staging.ottg.co.uk port 80 after 25 ms: Couldn't
826
877
connect to server
827
878
----
828
879
880
+ // DAVID: I was able to connect, and got Host not found.
881
+
829
882
Now let's ssh in and try `curl` from the server itself:
830
883
831
884
[subs="specialcharacters,quotes"]
@@ -892,6 +945,8 @@ selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
892
945
element: [id="id_list_table"]; [...]
893
946
----
894
947
948
+ // DAVID: tests pass for me now! And I can create lists on the server...
949
+ // Strange, I'm pretty sure I didn't run migrations.
895
950
896
951
=== Mounting the database on the server and running migrations
897
952
@@ -905,6 +960,7 @@ $ *ssh elspeth@server docker logs superlists*
905
960
django.db.utils.OperationalError: no such table: lists_list
906
961
----
907
962
963
+ // DAVID: confused by this next para.
908
964
909
965
[subs="specialcharacters,quotes"]
910
966
----
@@ -1001,6 +1057,7 @@ and reloads it automatically if it crashes.
1001
1057
(used to need systemd, now you can just set restart_policy.
1002
1058
////
1003
1059
1060
+ // DAVID: Maybe you should say this debugging stuff at the beginning, not the end!
1004
1061
1005
1062
.More Debugging Tips and Commands
1006
1063
*******************************************************************************
@@ -1114,7 +1171,10 @@ You now have a live website! Tell all your friends!
1114
1171
Tell your mum, if no one else is interested!
1115
1172
And, in the next chapter, it's back to coding again.((("", startref="Fstage11")))
1116
1173
1117
-
1174
+ // DAVID: maybe more of a conclusion here? It's quite a heavy chapter,
1175
+ // a bit of an anticlimax to stop here. I want some inspiring note to end on.
1176
+ // In particular, how does this tie into TDD?
1177
+ // DAVID: Also - now it's on staging, should we release to prod too?
1118
1178
1119
1179
=== Further Reading
1120
1180
0 commit comments