Skip to content

cachuperia/ansible-role-server-bootstrap

Repository files navigation

ansible-role-server-bootstrap

checks release

Table Of Contents

About

This Ansible role is designed to bootstrap a development server running Ubuntu 22.04 LTS.

Usage

Requirements

  • Minimum Ansible version: 2.10

Role Variables

cache_valid_time: 3600

apt_packages:
  - apt-transport-https
  - avahi-daemon
  - avahi-utils
  - byobu
  - ca-certificates
  - curl
  - direnv
  - git
  - gnupg-agent
  - htop
  - iotop
  - jq
  - lsb-release
  - make
  - multitail
  - podman
  - python3
  - python3-pip
  - software-properties-common
  - unzip
  - wget
  - whois

pyenv_version: 2.3.17

python_version: 3.10.11  # default Python for user

pipx_packages:
  - awscli
  - cookiecutter
  - detect-secrets
  - pre-commit
  - yq

asdf_version: 0.11.3
asdf_plugins:
  - name: github-cli
    repo: https://github.com/bartlomiejdanek/asdf-github-cli.git
  - name: lazydocker
    repo: https://github.com/comdotlinux/asdf-lazydocker.git
  - name: nodejs
    repo: https://github.com/asdf-vm/asdf-nodejs.git
  - name: packer
    repo: https://github.com/asdf-community/asdf-hashicorp.git
  - name: sops
    repo: https://github.com/feniix/asdf-sops.git
  - name: terraform
    repo: https://github.com/asdf-community/asdf-hashicorp.git
  - name: terraform-docs
    repo: https://github.com/looztra/asdf-terraform-docs
  - name: terragrunt
    repo: https://github.com/ohmer/asdf-terragrunt
  - name: tflint
    repo: https://github.com/skyzyx/asdf-tflint
asdf_global:
  - name: lazydocker
    version: latest
  - name: github-cli
    version: latest
  - name: sops
    version: latest

Role Tags

  • asdf - Install asdf, asdf_plugins and asdf_global tools, configure .bashrc.
  • base - Install apt_packages, configure .bashrc and .ssh/config for user.
  • docker - Configure official Docker repository as apt source, install docker tools and services.
  • pipx - Install pipix and pipx_packages, configure .bashrc.
  • poetry - Install/update poetry, configure .bashrc.
  • psql - Configure official PostgreSQL repository as apt source, install psql client.
  • python - Install/update pyenv, build Python python_version, and configure it as global for user.
  • vagrant - Install virtualbox and vagrant.

Usage Example

Create requirements.yml file:

# requirements.yml
roles:
  - src: git+ssh://[email protected]/cachuperia/ansible-role-server-bootstrap.git
    scm: git
    version: v1.1.0

Install role:

ansible-galaxy install -r requirements.yml

Create playbook.yml:

# playbook.yml
- hosts: servers
  roles:
    - role: ansible-role-server-bootstrap
      default_user_python_version: 3.11.11

Run playbook:

ansible-playbook playbook.yml --extra-vars "ansible_sudo_pass=<sudo password>" --tags "<tag1>,<tag2>" --skip-tags "<tag>"

Contributing

Commit message style - Conventional Commits.

Prerequisites

Tools to install: git, pre-commit, vagrant and detect-secrets.

You can use this playbook for automated tools installation.

Setup Local Environment

git clone [email protected]:cachuperia/ansible-role-server-bootstrap.git
cd ansible-role-server-bootstrap
make init

Run make to list all available targets.

Testing

make test

CD/CI

  • check GitHub workflow.
  • release GitHub workflow. Release commit types: fix, feat.