|
2 | 2 |
|
3 | 3 | # Ansible GitOps - Raspberry Pi OS custom disk image |
4 | 4 |
|
5 | | -A build tool based on [CustoPiZe](https://github.com/OctoPrint/CustoPiZer) to create a customized Raspberry Pi OS disk image which initiates the Ansible GitOps workflow on first boot. |
| 5 | +A build tool based on [CustoPiZe](https://github.com/OctoPrint/CustoPiZer) to create a custom Raspberry Pi OS disk image that starts the Ansible GitOps workflow on first boot. |
6 | 6 |
|
7 | 7 | ## How does it work? |
8 | 8 |
|
9 | | -The build tool downloads the latest [Raspberry Pi OS Lite (32-bit / 64-bit)](https://www.raspberrypi.com/software/operating-systems/) disk image and creates a systemd service inside it to bootstrap the Ansible GitOps workflow on first boot. |
| 9 | +The build tool downloads the latest [Raspberry Pi OS Lite (32-bit / 64-bit)](https://www.raspberrypi.com/software/operating-systems/) disk image and creates a systemd service in it that starts the Ansible GitOps workflow on first boot. |
10 | 10 |
|
11 | | -After the Raspberry Pi boots successfully with the customized disk image, the systemd service prepares all needed dependencies and runs [ansible-pull](https://docs.ansible.com/ansible/latest/cli/ansible-pull.html) with the user pre-configured environment variables. |
| 11 | +After the Raspberry Pi has successfully booted with the customized disk image, the systemd service prepares all required [dependencies](https://github.com/escalate/ansible-gitops-raspberry-pi-os-custom-disk-image/blob/master/scripts/files/gitops-preparation.sh) and executes a [bootstrap script](https://github.com/escalate/ansible-gitops-raspberry-pi-os-custom-disk-image/blob/master/scripts/files/gitops-bootstrap.sh) with the settings preconfigured by the user. |
12 | 12 |
|
13 | | -Ansible-pull checks out the pre-configured [Git repository](https://github.com/escalate/ansible-gitops-example-repository/) and runs the playbook `bootstrap.yml`. |
14 | | -All steps for the further process must be stored in the `bootstrap.yml` playbook e.g. the preparation of an external USB drive as well as a cronjob for the periodical execution of ansible-pull. |
| 13 | +The [bootstrap script](https://github.com/escalate/ansible-gitops-raspberry-pi-os-custom-disk-image/blob/master/scripts/files/gitops-bootstrap.sh) checks out the preconfigured [Git repository](https://github.com/escalate/ansible-gitops-example-repository/), installs required roles and collections and runs the `bootstrap.yml` playbook. |
| 14 | +The `bootstrap.yml` playbook must contain all steps for the further process, e.g. the preparation of an external USB drive and a cronjob for the regular execution of the [deployment script](https://github.com/escalate/ansible-gitops-raspberry-pi-os-custom-disk-image/blob/master/scripts/files/gitops-deployment.sh). |
15 | 15 |
|
16 | | -After the successful run of the playbook, a marker is set to prevent the systemd service from starting again at the next boot. Finally, the system is rebooted to complete all changes. |
| 16 | +After the successful run of the `bootstrap.yml` playbook, markers are set to prevent the scripts from being restarted at the next system start. Finally, the system is rebooted to complete all changes. |
17 | 17 |
|
18 | | -Any configuration change of the Raspberry Pi should now be possible via the configured Git repository. |
| 18 | +All configuration changes on the Raspberry Pi should now be possible via the `site.yml` of the configured [Git repository](https://github.com/escalate/ansible-gitops-example-repository/). |
19 | 19 |
|
20 | 20 | ## How to create a customized disk image? |
21 | 21 |
|
22 | | -1. Define necessary environment variables needed for the later ansible-pull run. |
| 22 | +1. Define necessary environment variables needed for the later ansible-playbook run. |
23 | 23 |
|
24 | 24 | ``` |
25 | | -export ANSIBLE_HOSTNAME='testserver.fritz.box' |
26 | | -export ANSIBLE_REPOSITORY_URL='https://github.com/escalate/ansible-gitops-example-repository.git' |
27 | | -export ANSIBLE_VAULT_PASSWORD='s3cret' |
| 25 | +# The Fully Qualified Domain Name (FQDN) of your server |
| 26 | +export ANSIBLE_HOSTNAME="testserver.fritz.box" |
| 27 | +" |
| 28 | +# The Ansible inventory group name where your server belongs to. For more information see https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html |
| 29 | +export ANSIBLE_HOSTGROUP="testing" |
| 30 | +
|
| 31 | +# The URL of your Ansible control repository |
| 32 | +export ANSIBLE_REPOSITORY_URL"=https://github.com/escalate/ansible-gitops-example-repository.git" |
| 33 | +
|
| 34 | +# The secret password to decrypt your Ansible Vault file. For more information see https://docs.ansible.com/ansible/latest/user_guide/vault.html |
| 35 | +export ANSIBLE_VAULT_PASSWORD="s3cret" |
28 | 36 | ``` |
29 | 37 |
|
30 | 38 | 2. Start the build process with one of the following commands. |
|
0 commit comments