@@ -10,16 +10,19 @@ plugins](https://docs.ansible.com/ansible/2.6/plugins/connection.html) for perfo
10
10
11
11
tl;dr Ansible is the frontend, buildah is the backend.
12
12
13
- I described this concept a while ago in [ this blog post] ( https://blog.tomecek.net/post/building-containers-with-buildah-and-ansible/ ) .
13
+ I described this concept in these blog posts:
14
+ * [ Building containers with buildah and ansible] ( https://blog.tomecek.net/post/building-containers-with-buildah-and-ansible/ ) .
15
+ * [ Ansible and Podman Can Play Together Now] ( https://blog.tomecek.net/post/ansible-and-podman-can-play-together-now/ )
14
16
15
17
You may be asking: why not
16
- [ ansible-container] ( https://github.com/ansible/ansible-container ) ? This tool is
18
+ [ ansible-container] ( https://github.com/ansible/ansible-container ) ? Ansible bender is
17
19
actually heavily inspired by ansible-container: the main distinction is that
18
20
ansible-container covers the complete lifecycle of a containerized application
19
21
while ab takes care of image builds only.
20
22
21
23
** Please note that this project is not affiliated with the Ansible project.
22
- It's just using Ansible to do something magical.**
24
+ Even though I work for Red Hat, I am not on the Ansible team. I wrote the tool
25
+ because I care about the problem it solves.**
23
26
24
27
25
28
** Status** : proof of concept
@@ -42,33 +45,39 @@ It's just using Ansible to do something magical.**
42
45
* You can turn this off with ` --no-cache ` .
43
46
* You can disable caching from a certain point by adding a tag ` no-cache ` to a task.
44
47
* You can stop creating new image layers by adding tag ` stop-layering ` to a task.
48
+ * If an image build fails, it's comitted and named with a suffix ` -failed ` (so
49
+ you can take a look inside and resolve the issue).
45
50
46
51
47
- ## Subcommands
52
+ ## Interface
48
53
49
- * ` build ` — build a new container image using selected playbook
50
- * ` list-builds ` — list all builds
51
- * ` get-logs ` — display build logs
52
- * ` inspect ` — provide detailed metadata about the selected build
54
+ ab has these commands:
53
55
56
+ Command | Description
57
+ --------|------------
58
+ ` build ` | build a new container image using selected playbook
59
+ ` list-builds ` | list all builds
60
+ ` get-logs ` | display build logs
61
+ ` inspect ` | provide detailed metadata about the selected build
54
62
55
- ## Installation
56
63
57
- ` ansible-bender ` will be on PyPI starting from version ` 0.2.0 ` .
64
+ ## Installation
58
65
59
- In the meantime, please install it from github directly:
60
66
```
61
- $ pip3 install --user git+https://github.com/TomasTomecek/[email protected]
67
+ $ pip3 install ansible-bender
62
68
```
63
69
64
- Oh right, and ab is tested only with python 3.
70
+ Ansible bender supports python 3 only. This means that you need to have a
71
+ python3 interpretter inside your base image.
65
72
66
73
67
74
## Usage
68
75
69
76
You may noticed that I refer to ` ansible-bender ` as ab. That was the initial
70
77
name and also the name of the CLI tool, so I decided to stick to it.
71
78
79
+ ### Building images
80
+
72
81
If you clone this repository, you can utilize a simple playbook I am using for testing:
73
82
```
74
83
$ ab build -e SOME=VALUE -l some=other-value -- ./tests/data/basic_playbook.yaml docker.io/library/python:3-alpine this-is-my-image
@@ -139,9 +148,6 @@ $ ab build \ # this is the command
139
148
this-is-my-image \ # and finally, target image name
140
149
```
141
150
142
- At some point, I should figure out a file-format where these would live (ansible variables? a dedicated file?).
143
-
144
-
145
151
If we rerun the build again, we can see that ab loads every task from a cache:
146
152
```
147
153
$ ab build -e SOME=VALUE -l some=other-value -- ./tests/data/basic_playbook.yaml docker.io/library/python:3-alpine this-is-my-image
@@ -188,6 +194,9 @@ Storing signatures
188
194
Image 'this-is-my-image' was built successfully \o/
189
195
```
190
196
197
+
198
+ ### Listing builds
199
+
191
200
We can list builds we have done:
192
201
```
193
202
BUILD ID IMAGE NAME STATUS DATE BUILD TIME
@@ -196,6 +205,9 @@ We can list builds we have done:
196
205
2 this-is-my-image BuildState.DONE 2018-10-31 12:19:27.341574 0:00:10.252394
197
206
```
198
207
208
+
209
+ ### Getting logs of a build
210
+
199
211
Wanna check build logs sometime later? No problem!
200
212
```
201
213
$ ab get-logs 2
@@ -225,6 +237,9 @@ PLAY RECAP *********************************************************************
225
237
this-is-my-image-20181031-121917088731-cont : ok=1 changed=0 unreachable=0 failed=0
226
238
```
227
239
240
+
241
+ ### Locating built images with podman
242
+
228
243
Here is a proof that the image is in there:
229
244
```
230
245
$ podman images
0 commit comments