https://github.com/debovema/ansible_setup
Quickly configure workstation or server with Ansible
https://github.com/debovema/ansible_setup
ansible config-management configuration server workstation
Last synced: about 2 months ago
JSON representation
Quickly configure workstation or server with Ansible
- Host: GitHub
- URL: https://github.com/debovema/ansible_setup
- Owner: debovema
- License: bsd-3-clause
- Created: 2022-10-12T12:26:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-25T14:37:44.000Z (10 months ago)
- Last Synced: 2025-07-31T02:15:42.511Z (10 months ago)
- Topics: ansible, config-management, configuration, server, workstation
- Language: Shell
- Homepage:
- Size: 42 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ansible setup
Ansible setup playbooks for workstation or server.
## Usage
The playbooks are designed to be used with an Ansible inventory to target one or several *hosts*
belonging to one or several *groups*.
### Requirements
* Python 3
* A Python *virtual environment* configured with Ansible and its requirements
#### Create a Python virtual environment with Ansible
To create a Python *virtual environment* and install Ansible inside, run:
```shell
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install ansible
```
#### Python requirements
To install the required Python packages, run:
```shell
pip install -r requirements.txt
```
#### Roles and Collections
Before running the actual playboook, it is needed to install required roles
and collections. This can be done with a simple command:
```shell
ansible-galaxy install -r requirements.yml
```
### Run a Playbook
#### Workstation
First create your inventory, for instance:
```shell
cat > ./inventory.yml < ./inventory.yml <" defined at the "all/children//hosts/" inventory path
timezone: "Europe/Paris" # the timezone for the server
# Features
feature_docker: true # add Docker packages (users with docker flag will be able to use it)
feature_ohmyzsh: true # install Oh My Zsh
oh_my_zsh_theme: ys # the theme for Oh My Zsh
users: # users to create (or update) and their configuration
- username: root
- username: mathieu
ssh_authorized_keys: https://github.com/debovema.keys
sudoernopassword: true
docker: true
children:
scaleway: # a group to categorize your hosts (e.g. the Cloud provider is 'scaleway')
hosts:
devno1-3:
ansible_host: 163.123.45.67
hetzner: # a group to categorize your hosts (e.g. the Cloud provider is 'hetzner')
hosts:
devno1-4:
ansible_host: 2a01:4ff:123:456::2
# Hetzner rescue mode installation (optional)
hetzner_install_disk_by_id_pattern: "*SAMSUNG*"
hetzner_install_image: Debian-1202-bookworm-amd64-base.tar.gz
# Features
feature_wireguard_4in6_tunnel: true # copy wgclient.conf file in ansible/roles/wireguard_4in6_tunnel/files directory
EOF
```
```shell
# Check run and show diffs
ansible-playbook -i inventory.yml --check --diff ansible/playbooks/server/configure.yml
# Execute the playbook
ansible-playbook -i inventory.yml ansible/playbooks/server/configure.yml
```
#### Hetzner server
If using Hetzner hosts with rescue mode enabled, install and configure the hosts automatically:
```shell
ansible-playbook -i inventory.yml ansible/playbooks/hetzner/install.yml ansible/playbooks/server/configure.yml --limit 'hetzner'
```
> If a host is not in rescue mode, the installation playbook will be ignored silently
## Fully remote usage
1. Install this collection and its requirements:
```shell
ansible-galaxy collection install debovema.ansible_setup
ansible-playbook debovema.ansible_setup.meta.requirements
```
2. Retrieve your inventory from a custom Ansible setup inventory repository (for instance: [debovema/ansible_setup_inventory](https://github.com/debovema/ansible_setup_inventory)), created with the [Ansible setup inventory template](https://github.com/debovema/ansible_setup_inventory_template):
```shell
git clone git@github.com:debovema/ansible_setup_inventory.git ~/.ansible_setup_inventory
```
3. Execute the server configuration playbook:
```shell
cd ~/.ansible_setup_inventory
ansible-playbook debovema.ansible_setup.server.configure all
```