Skip to content

Commit 899fe00

Browse files
committed
switch ottg.eu to ottg.co.uk. a bit in 11
1 parent 616062d commit 899fe00

9 files changed

+96
-72
lines changed

appendix_IV_testing_migrations.asciidoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ constraints in <<chapter_deploying_validation>>:
3434
[subs="specialcharacters,macros"]
3535
----
3636
$ pass:quotes[*cd deploy_tools*]
37-
$ pass:quotes[*fab deploy:host=elspeth@superlists-staging.ottg.eu*]
37+
$ pass:quotes[*fab deploy:[email protected].co.uk*]
3838
[...]
3939
Running migrations:
4040
Applying lists.0005_list_item_unique_together...Traceback (most recent call
@@ -88,8 +88,8 @@ Copy the database down from live:
8888

8989
[subs="specialcharacters,quotes"]
9090
----
91-
$ *scp [email protected].eu:\
92-
/home/elspeth/sites/superlists.ottg.eu/database/db.sqlite3 .*
91+
$ *scp [email protected].co.uk:\
92+
/home/elspeth/sites/superlists.ottg.co.uk/database/db.sqlite3 .*
9393
$ *mv ../database/db.sqlite3 ../database/db.sqlite3.bak*
9494
$ *mv db.sqlite3 ../database/db.sqlite3*
9595
----
@@ -197,7 +197,7 @@ We're now ready to run our test against the live data:
197197
[subs="specialcharacters,macros"]
198198
----
199199
$ pass:quotes[*cd deploy_tools*]
200-
$ pass:quotes[*fab deploy:host=elspeth@superlists-staging.ottg.eu*]
200+
$ pass:quotes[*fab deploy:[email protected].co.uk*]
201201
[...]
202202
----
203203

@@ -206,7 +206,7 @@ We'll need to restart the live Gunicorn job too:
206206
[role="server-commands skipme"]
207207
[subs="specialcharacters,quotes"]
208208
----
209-
elspeth@server:$ *sudo systemctl restart gunicorn-superlists.ottg.eu*
209+
elspeth@server:$ *sudo systemctl restart gunicorn-superlists.ottg.co.uk*
210210
----
211211

212212

@@ -215,7 +215,7 @@ And we can now run our FTs against staging:
215215
[role="skipme small-code"]
216216
[subs="specialcharacters,macros"]
217217
----
218-
$ pass:quotes[*STAGING_SERVER=superlists-staging.ottg.eu python manage.py test functional_tests*]
218+
$ pass:quotes[*STAGING_SERVER=staging.ottg.co.uk python manage.py test functional_tests*]
219219
[...]
220220
....
221221
---------------------------------------------------------------------
@@ -231,8 +231,8 @@ Everything seems in order! Let's do it against live:
231231
[role="skipme"]
232232
[subs="specialcharacters,macros"]
233233
----
234-
$ pass:quotes[*fab deploy:host=superlists.ottg.eu*]
235-
[superlists.ottg.eu] Executing task 'deploy'
234+
$ pass:quotes[*fab deploy:host=superlists.ottg.co.uk*]
235+
[superlists.ottg.co.uk] Executing task 'deploy'
236236
[...]
237237
----
238238

chapter_11_ansible.asciidoc

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ NOTE: Why not ping me a note once your site is live on the web,
3434
It always gives me a warm and fuzzy feeling...
3535
3636

37-
//TODO useful blog post https://linuxhandbook.com/autostart-podman-containers/
3837

3938

4039
.🚧 Warning, this chapter is heavily under construction
@@ -58,7 +57,7 @@ But otherwise it might be best to skip ahead to <<chapter_12_organising_test_fil
5857
((("domain names")))
5958
We're going to need a couple of domain names at this point in the book--they
6059
can both be subdomains of a single domain. I'm going to use
61-
_superlists.ottg.eu_ and _superlists-staging.ottg.eu_.
60+
_superlists.ottg.co.uk_ and _staging.ottg.co.uk_.
6261
If you don't already own a domain, this is the time to register one!
6362
Again, this is something I really want you to _actually_ do.
6463
If you've never registered a domain before,
@@ -76,8 +75,8 @@ I promise seeing your site on a "real" website will be a thrill.
7675
((("server provisioning", id="seerver09")))
7776
We can separate out "deployment" into two tasks:
7877

79-
- 'Provisioning' a new server to be able to host the code
80-
- 'Deploying' a new version of the code to an existing server
78+
- _Provisioning_ a new server to be able to host the code
79+
- _Deploying_ a new version of the code to an existing server
8180

8281
Ultimately, infrastructure-as-code tools can let you automate both of these,
8382
but for the purposes of this book, we can live with manual provisioning.
@@ -119,10 +118,10 @@ from all the grizzled dinosaurs out there.
119118

120119
==== Spinning Up a Server
121120

122-
I'm not going to dictate how you do this--whether you choose Amazon AWS,
123-
Rackspace, Digital Ocean, your own server in your own data centre or a
124-
Raspberry Pi in a cupboard under the stairs, any solution should be fine,
125-
as long as:
121+
I'm not going to dictate how you do this--whether
122+
you choose Amazon AWS, Rackspace, Digital Ocean, your own server in a data centre,
123+
or a Raspberry Pi in a cupboard under the stairs,
124+
any solution should be fine, as long as:
126125

127126
* Your server is running Ubuntu 22.04 (aka "Jammy/LTS").
128127

@@ -144,8 +143,9 @@ https://github.com/hjwp/Book-TDD-Web-Dev-Python/blob/master/server-quickstart.md
144143

145144
NOTE: Some people get to this chapter, and are tempted to skip the domain bit,
146145
and the "getting a real server" bit, and just use a VM on their own PC.
147-
Don't do this. It's _not_ the same, and you'll have more difficulty
148-
following the instructions, which are complicated enough as it is.
146+
Don't do this.
147+
It's _not_ the same, and you'll have more difficulty following the instructions,
148+
which are complicated enough as it is.
149149
If you're worried about cost, have a look at the link above for free options.
150150
((("getting help")))
151151

@@ -205,9 +205,9 @@ DNS records take some time to "propagate" around the world
205205
(it's controlled by a setting called "TTL", Time To Live),
206206
so once you've set up your A-record,
207207
you can check its progress on a "propagation checking" service like this one:
208-
https://www.whatsmydns.net/#A/superlists-staging.ottg.eu.
208+
https://www.whatsmydns.net/#A/staging.ottg.co.uk.
209209

210-
I'm planning to host my staging server at 'superlists-staging.ottg.eu':
210+
I'm planning to host my staging server at 'staging.ottg.co.uk':
211211

212212

213213
=== A first Cut of an Ansible Script
@@ -253,18 +253,42 @@ TODO: forget podman, just use docker.
253253
- hosts: all
254254
255255
tasks:
256-
- name: Install podman <1>
257-
ansible.builtin.apt: <2>
258-
name: podman <3>
259-
update_cache: yes
260-
become: true
261256
262-
- name: Run container
263-
containers.podman.podman_container:
257+
- name: Install docker <1>
258+
become: true
259+
block:
260+
- name: Add Docker GPG apt Key
261+
ansible.builtin.apt_key: <2>
262+
url: https://download.docker.com/linux/ubuntu/gpg
263+
state: present
264+
265+
- name: Add Docker Repository
266+
ansible.builtin.apt_repository:
267+
repo: deb https://download.docker.com/linux/ubuntu jammy stable
268+
state: present
269+
270+
- name: Update apt and install docker-ce
271+
ansible.builtin.apt:
272+
name: docker-ce
273+
state: latest
274+
update_cache: true
275+
276+
- name: Install Docker Module for Python
277+
ansible.builtin.pip:
278+
name: docker
279+
280+
- name: Add our user to Docker allowed users
281+
ansible.builtin.user:
282+
name: elspeth
283+
groups: docker
284+
append: true
285+
286+
- name: Run test container
287+
community.docker.docker_container:
264288
name: testcontainer
265-
image: busybox
266289
state: started
267-
cmd: echo hello world
290+
image: busybox
291+
command: echo hello world
268292
----
269293
====
270294

@@ -274,7 +298,7 @@ TODO: forget podman, just use docker.
274298
Each one usually has a human-readable `name` attribute.
275299

276300
<2> Each tasks uses an ansible "module" to do its work.
277-
This one uses the `builtin.apt` module which provides
301+
The next few use the `builtin.apt` module which provides
278302
a wrapper around the `apt` Debian & Ubuntu package management tool.
279303

280304
<3> Each module then provides a bunch of parameters which control
@@ -292,7 +316,7 @@ $ *ansible-playbook --user=elspeth -i 192.168.56.10, infra/ansible-provision.yam
292316
----
293317

294318
TODO: show ansible output.
295-
TODO: stop using local ip
319+
TODO: stop using local ip
296320

297321

298322
=== SSHing Into the Server and Viewing Container Logs
@@ -542,7 +566,7 @@ self-explanatory.
542566
[role="small-code"]
543567
[subs="specialcharacters,macros"]
544568
----
545-
$ pass:quotes[*TEST_SERVER=superlists-staging.ottg.eu python manage.py test functional_tests*]
569+
$ pass:quotes[*TEST_SERVER=staging.ottg.co.uk python manage.py test functional_tests*]
546570
[...]
547571
OK
548572
----
@@ -601,10 +625,10 @@ So, let's try using it for our live site!
601625
[role="small-code against-server"]
602626
[subs=""]
603627
----
604-
$ <strong>fab deploy:[email protected].eu</strong>
628+
$ <strong>fab deploy:[email protected].co.uk</strong>
605629
606630
Done.
607-
Disconnecting from [email protected].eu... done.
631+
Disconnecting from [email protected].co.uk... done.
608632
----
609633

610634

chapter_deploying_validation.asciidoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ We start with the staging server:
2626
----
2727
$ pass:quotes[*git push*]
2828
$ pass:quotes[*cd deploy_tools*]
29-
$ pass:quotes[*fab deploy:host=elspeth@superlists-staging.ottg.eu*]
29+
$ pass:quotes[*fab deploy:[email protected].co.uk*]
3030
[...]
31-
Disconnecting from superlists-staging.ottg.eu... done.
31+
Disconnecting from staging.ottg.co.uk... done.
3232
----
3333

3434
Restart Gunicorn:
3535

3636
[role="server-commands skipme"]
3737
[subs="specialcharacters,quotes"]
3838
----
39-
elspeth@server:$ *sudo systemctl restart gunicorn-superlists-staging.ottg.eu*
39+
elspeth@server:$ *sudo systemctl restart gunicorn-staging.ottg.co.uk*
4040
----
4141

4242
And run the tests against staging:
4343

4444
[role="small-code"]
4545
[subs="specialcharacters,macros"]
4646
----
47-
$ pass:quotes[*STAGING_SERVER=superlists-staging.ottg.eu python manage.py test functional_tests*]
47+
$ pass:quotes[*STAGING_SERVER=staging.ottg.co.uk python manage.py test functional_tests*]
4848
OK
4949
----
5050

@@ -61,13 +61,13 @@ Assuming all is well, we then run our deploy against live:
6161
[role="against-server"]
6262
[subs="specialcharacters,macros"]
6363
----
64-
$ pass:quotes[*fab deploy:[email protected].eu*]
64+
$ pass:quotes[*fab deploy:[email protected].co.uk*]
6565
----
6666

6767
[role="server-commands"]
6868
[subs="specialcharacters,quotes"]
6969
----
70-
elspeth@server:$ *sudo service gunicorn-superlists.ottg.eu restart*
70+
elspeth@server:$ *sudo service gunicorn-superlists.ottg.co.uk restart*
7171
----
7272

7373

0 commit comments

Comments
 (0)