playbooks,inventory: added playbook installing basic tools on a VM

As soon as a virtual machine is ready, we install docker as it gives
the most flexbility for our CI and the docker images are versionized.
Hence, we install docker as main installation package.
We assume that the VM holds the following users:
- root
- superuser (added to sudoers)
- user

Signed-off-by: Marc Mattmüller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmüller 2023-05-15 18:18:19 +02:00
parent 9e6a6d7c8d
commit c37bd6f380
2 changed files with 65 additions and 0 deletions

View File

@ -2,3 +2,4 @@ linux:
hosts:
192.168.40.221:
rls_info_path: /etc/os-release
user_name: user

View File

@ -0,0 +1,64 @@
- name: Setup Basic Debian Host Machine
hosts: linux
become: yes
tasks:
- name: Update Apt Cache and Upgrade all Packages
register: updatesys
apt:
name: "*"
state: latest
update_cache: yes
cache_valid_time: 3600 #1 hour
become: yes
- name: Display the last line of the previous task to check the stats
debug:
msg: "{{updatesys.stdout_lines|last}}"
- name: Install First Basic Packages
apt:
name:
- git
- tree
- vim
- rsync
- ca-certificates
- curl
- gnupg
- python3-pip
become: yes
- name: Adding Docker's GPG key and Setup the apt repository for Debian
ansible.builtin.shell: |
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
become: yes
- name: Update the apt Cache with the new Docker repository
apt:
update_cache: yes
become: yes
- name: Install Docker Engine
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
become: yes
- name: Install docker-compose with pip3
ansible.builtin.pip:
name: docker-compose
state: latest
become: yes
- name: Adding user {{user_name}} to the docker group
ansible.builtin.shell: |
groupadd docker
usermod -aG docker {{user_name}}
become: yes