@@ -541,8 +541,9 @@ This means we don't have a dependency on having run `docker build` locally.
541
541
source: build
542
542
state: present
543
543
build:
544
- path: ../Dockerfile
544
+ path: ..
545
545
platform: linux/amd64 # <1>
546
+ force_source: true
546
547
delegate_to: 127.0.0.1
547
548
548
549
- name: Export container image locally
@@ -668,17 +669,37 @@ And here's how we use it in the provisioning script:
668
669
but I'm renaming it for clarity.
669
670
670
671
671
- .Idempotency
672
- *******************************************************************************
673
- * TODO: explain idempotency
674
-
675
- *******************************************************************************
676
-
677
672
NOTE: Using an env file to store secrets is definitely better than committing
678
673
it to version control, but it's maybe not the state of the art either.
679
674
TODO: mention other secret management tools. vault
680
675
681
676
677
+ .Idempotency and Declarative Configuration
678
+ *******************************************************************************
679
+
680
+ Infrastucture-as-code tools like Ansible aim to be "declarative",
681
+ meaning that, as much as possible, you specify the desired state that you want,
682
+ rather than specifying a series of steps to get there.
683
+
684
+ This concept goes along with the idea of "idempotency",
685
+ which means that you get the same result when you run something once,
686
+ as when you run it multiple times.
687
+
688
+ An example is the `apt` module that we used to install docker.
689
+ It doesn't crash if docker is already installed, and in fact,
690
+ Ansible is smart enough to check first before trying to install anything.
691
+
692
+ There is some subtlety here, for example, our templated env file
693
+ will only be writen once, so the step is idempotent in the sense
694
+ that it doesn't overwrite the file with a new random secret key every time you run it.
695
+ But that does come with the downside that you can't easily add new variables to the file.
696
+
697
+ Probably a more sophisticated solution involving separate files for the secret
698
+ and other parts of the config would be better,
699
+ but I wanted to keep this (already long) chapter as simple as possible.
700
+
701
+ *******************************************************************************
702
+
682
703
683
704
==== More debugging
684
705
0 commit comments