This ansible playbook is used by me to automate the setup of my Linux developer machines. If you frequently reinstall your system, you know why these scripts were created. Therefore, this repository will be updated whenever I setup a new machine (commits to master).
Right now the only tested Distributions are:
- Fedora 43
.
├── bootstrap_local.sh // Script to bootstrap the ansible environment before executing the playbook
├── site.yml // Playbook that wraps all tasks, roles, ...
├── ...
├── roles/ // Roles to be executed by the playbook
│ ├── common // Installation of common tools, external repos (rpm-fusion...), etc.
│ ├── user // Creation of users
│ ├── zsh // Installation of zsh for each user
│ ├── vscode // Installation of Visual Studio Code
│ ├── ansible // Installation of Ansible and linting tools
│ ├── cpp // Everything needed for C(pp) development
│ ├── go // Everything needed for Golang development
│ ├── java // Everything needed for Java development
│ ├── kubernetes // Everything needed for Kubernetes development (minikube, helm, ...)
│ ├── python // Everything needed for Python development
│ └── ruby // Everything needed for Ruby development
│ ├── virtualization // Virtualization tools (VirtualBox, Vagrant)
│ └── intellij // Installation of IntelliJ IDEA
│ └── ai // AI tools (Ollama, PyTorch, Jupyter)
└── test/ // Test the playbook in docker images
└── docker/
First of all, clone this repository.
git clone https://github.com/ottenwbe/developer-environment-setup.git
The bootstrap_local.sh script installs ansible as a prerequisite for executing the playbook.
On a local Fedora installation where ansible is not (yet) installed the playbook can be executed as follows. The playbook will install ansible and start sshd:
sh bootstrap_local.sh inventory.yml @vars.jsonThis expects a simple config, vars.json, like this to setup your users and all configurations in their respective home directories:
{
"users": [
{
"username": "user1",
},
{
"username": "user2",
}
]
}On a local Linux installation where ansible is installed the playbook can be executed as follows. NOTE: in this example the git config is updated as well for the user, which is an optional step:
ansible-playbook -i inventory.yml site.yml --connection=local --extra-vars '{"users": [{"username": "your user", "git_name": "Your Name", "git_email": "email@example.com"}]}' --ask-become-passThe playbook uses tags to allow running specific parts of the setup.
Available tags:
- system: Runs all system setup roles (user, zsh, vscode, ansible, common)
- dev: Runs all development environment roles (go, java, ruby, cpp, python, kubernetes, virtualization)
- user: User creation and configuration
- zsh: ZSH shell setup
- vscode: Visual Studio Code installation
- ansible: Ansible installation
- common: Common tools and repositories
- go: Go development environment
- java: Java development environment
- ruby: Ruby development environment
- cpp: C++ development environment
- python: Python development environment
- kubernetes: Kubernetes tools (Minikube, Helm, etc.)
- virtualization: Virtualization tools (VirtualBox, Vagrant)
- intellij: IntelliJ IDEA installation
To run only specific tags:
ansible-playbook -i inventory.yml site.yml ... --tags "tag1,tag2" Or using the bootstrap script (4th argument):
sh bootstrap_local.sh inventory.yml <extra-vars> Fedora "tag1,tag2" true You can customize the installation by overriding default variables using --extra-vars.
For example, if you have the need to install IntelliJ IDEA Ultimate instead of the default Community edition:
ansible-playbook ... --extra-vars '{"intellij_edition": "ultimate"}' The playbook can be tested in a Docker container---more or less.
NOTE: On an SELinux, i.e., Fedora, first execute the following command in the root directory of the project.
chcon -Rt svirt_sandbox_file_t "${PWD}"On a non SELinux you can simply build a docker image and execute the playbook in a container. Replace one of the 'testuser's' with a username that suits you and run the following commands:
docker build --file=test/docker/Dockerfile.fedora --build-arg "FEDORA_VERSION=43" --tag=fedora43:ansible test/docker
docker run --name=test-fedora --rm --volume="${PWD}":/home/ansible:ro fedora43:ansible ansible-playbook -i /home/ansible/test/docker/inventory.yml /home/ansible/site.yml --connection=local --become --extra-vars '{"users": [{"username": "testuser1"}, {"username": "testuser2"}]}' --skip-tags "common"or simply use the test scripts
sh test/test.sh 43 allNote: We skip everything related to systemd, since systemd is not monitoring our services in the container.
After the test has finished you can stop the container and remove it:
docker rm test-fedoraI created this project for the purpose of educating myself and personal use. If you are interested in the outcome, feel free to contribute; this work is published under the MIT license.