Easily Bootstrapping Arch Linux with Chef: A Workaround
Chef is an automation platform that transforms infrastructure into code. However, Arch Linux is not officially supported by Chef.io. This article will provide a workaround to bootstrap Arch Linux nodes using knife bootstrap command.
Prerequisites
- A working Chef development environment
- An Arch Linux machine or virtual machine
Installing Chef on Arch Linux
The official Chef package is not available in the Arch Linux repository. Therefore, we need to install it manually. Here are the steps to install Chef on Arch Linux:
- Add the Chef repository:
# curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk
- Install the Chef development kit:
# sudo pacman -S chefdk
Bootstrapping Arch Linux Node
By default, the knife bootstrap command does not support Arch Linux. However, we can use a workaround to bootstrap an Arch Linux node. Here are the steps:
- Create a bootstrap template:
# sudo mkdir -p /etc/chef/bootstraptemplates/archlinux
# sudo touch /etc/chef/bootstraptemplates/archlinux/bootstrap.erb
- Edit the bootstrap template:
# sudo nano /etc/chef/bootstraptemplates/archlinux/bootstrap.erb
Add the following content to the bootstrap template:
#!/bin/bash
curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk
sudo chefdk install
sudo mkdir -p /etc/chef/first-boot.d
cat > /etc/chef/first-boot.d/01-bootstrap.sh <
- Bootstrap the Arch Linux node:
# sudo knife bootstrap archlinux_node_name \
--ssh-user user \
--ssh-password password \
--template-file /etc/chef/bootstraptemplates/archlinux/bootstrap.erb \
--node-name archlinux_node_name \
--run-list "recipe[my_cookbook::default]" \
--json-attributes '{"authorization": {"chef\_zero": {"environment\_url": "http://localhost:8889/organizations/my\_org"}}}'
In this article, we have provided a workaround to bootstrap Arch Linux nodes using the knife bootstrap command. We have created a bootstrap template and modified the bootstrap command to install Chef on the Arch Linux node and run a recipe.
References
- Chef Development Kit on Arch Linux: https://wiki.archlinux.org/title/Chef_Development_Kit
- Chef Bootstrap Templates: https://docs.chef.io/workstation/knife/bootstrap/#templates
Types of references:
- Online resources