Ansible Armbian Firstboot Server
Ansible AF is a server to automate the first boot configuration of Armbian servers using Armbian's Automatic First Boot Configuration and Ansible.
- You prepare a custom Armbian image with a
/root/.not_logged_in_yet
file that contains only this line:PRESET_CONFIGURATION="http://<server_ip>:<port>/register/<config_template>"
- Flash and boot your device with your custom image
- Your device will request a DHCP address
- (optional) Your DHCP server will register the host's mac address, allowing you to use dynamic DHCP IPs for first boot and static IPs after that
- When the first boot is complete, Armbian will register with Ansible AF to get a first boot configuration
- Armbian will apply the first boot configuration, including a static network configuration
- Armbian AF will run the configured Ansible Playbook(s) against the host
To use the Ansible Armbian Firstboot Server, you must have:
- Installed Ansible on your system.
- Built an inventory in
/etc/ansible/hosts
- Built one or more Armbian First Boot Configuariton Templates
- These should be located in
/etc/ansible/playbooks/tempates/
- These should be located in
- Built one or more Ansible Playbooks for configuring your system
- These should be located in
/etc/ansible/playbooks/
- These should be located in
IMPORTANT NOTE: The name of the First Boot Configuration Template (minus the .j2 extension) must match the name of the Ansible Playbook (minus the .yaml extension) and these both must match the <config_template>
you supply in the PRESET_CONFIGURATION
URL. By default this is armbian_first_boot
, so you would have /etc/ansible/playbooks/armbian_first_boot.yaml
and /etc/ansible/playbooks/template/armbian_first_boot.j2
.
First, customize the playbook in examples/etc-ansible-playbooks-ansible_af.yaml
if you want to change the defaults.
Install the service using ansible:
ansible-playbook -i /etc/ansible/hosts examples/etc-ansible-playbooks-ansible_af.yaml
You can use another location if you prefer.
If you already have Armbian AF installed, you can upgrade it to the latest version from git using the upgrade playbook:
ansible-playbook -i /etc/ansible/hosts examples/etc-ansible-playbooks-ansible_af-upgrade.yaml
Systemd unit files will be installed in /etc/systemd/system
. If you'd like to customize the location of Ansible or change other settings, you can edit the files and change the Environment=
lines. Make sure to reload and restart when you're done:
sudo systemctl daemon-reload
sudo systemctl restart ansible-af-http ansible-af-runner
Ansible AF is configured through environment variables. You can also set variables supported by Ansible and they will be passed through.
Variable Name | Default Value | Description |
---|---|---|
ANSIBLE_PATH |
/etc/ansible |
The base path where ansible files are located |
ANSIBLE_INVENTORY_PATH |
$ANSIBLE_PATH/hosts |
The path to the ansible inventory |
ANSIBLE_PLAYBOOK_PATH |
$ANSIBLE_PATH/playbooks |
The path to the ansible playbooks |
ANSIBLE_AF_TEMPLATE_DIR |
$ANSIBLE_PLAYBOOK_PATH/templates |
The path to ansible tempate files |
ANSIBLE_AF_ALLOWLIST |
armbian_first_boot* |
Templates allowed to be rendered. Can supply a comma separated list. Shell style wildcards (* , ? , [a-z] ) supported. |
ANSIBLE_AF_DENYLIST |
Templates disallowed from rendering. Same format as ANSIBLE_AF_ALLOWLIST , takes precedence. |
|
ANSIBLE_AF_HOST_WAIT |
30 |
Minimum time to wait between host registration and running the playbook. |
ANSIBLE_AF_HOST_IP_KEY |
cluster_ip |
This key will be used to match a registration to the ansible inventory. It must exist in your inventory and match the IP the registration request comes from. |
ANSIBLE_AF_SSH_USERNAME |
The ssh username to connect as when running the playbook. Defaults to the user running armbian-af-runner . |
These steps require an SD card, USB drive, or another block device. You must perform them on Linux. You will not be able to mount the filesystem on Windows or macOS.
Warning: This will erase the device you use. Ensure you are performing these steps against the correct device.
- Download an Armbian image for your device
- Uncompress the image:
unxz Armbian_24.11.1_Rpi4b_bookworm_current_6.6.60_minimal.img.xz
- Ensure that your block device is empty. Change
/dev/sda
to whatever your drive actually is.dd if=/dev/zero of=/dev/sda bs=4k
- Write Armbian to your device:
dd if=Armbian_24.11.1_Rpi4b_bookworm_current_6.6.60_minimal.img.xz of=/dev/sda bs=4k
- Mount the Armbian root partition
mount /dev/sda2 /mnt
- Create the first boot file:
echo PRESET_CONFIGURATION="http://<server_ip>/register/<profile_name>"
- Unmount the Armbian root partition
umount /mnt
- Make a custom image you can write to other machines
dd conv=sparse if=/dev/sda of=Armbian_24.11.1_Rpi4b_bookworm_current_6.6.60_MY_ARMBIAN_AF_IMAGE.img.xz bs=4k
- Boot your machine from the drive you just made and watch it automagically boot and configure itself
Contributions are welcome! Fork the repository and create a pull request with your changes.
Please review our Code of Conduct before contributing.
This project is licensed under the MIT License.
For any questions or suggestions, feel free to open an issue or pull request.