From 9e76cd40aa62cd79d2d341409a7d6352d83b23e3 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 10 Aug 2020 22:53:13 +0200 Subject: [PATCH] Add basic roles --- playbook.yml | 13 ++++++++++ roles/common/tasks/main.yml | 12 +++++++++ roles/docker/defaults/main.yml | 7 ++++++ roles/docker/tasks/main.yml | 42 ++++++++++++++++++++++++++++++++ roles/python-base/tasks/main.yml | 19 +++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 playbook.yml create mode 100644 roles/common/tasks/main.yml create mode 100644 roles/docker/defaults/main.yml create mode 100644 roles/docker/tasks/main.yml create mode 100644 roles/python-base/tasks/main.yml diff --git a/playbook.yml b/playbook.yml new file mode 100644 index 0000000..d95d1e6 --- /dev/null +++ b/playbook.yml @@ -0,0 +1,13 @@ +--- +- hosts: all + gather_facts: false + roles: + - role: python-base + +- hosts: all + roles: + - role: common + tags: ['common'] + - role: docker + when: docker + tags: ['docker'] diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml new file mode 100644 index 0000000..1ad8dab --- /dev/null +++ b/roles/common/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- name: Install goodies + apt: pkg={{ item }} state=present + with_items: + - apticron + - unattended-upgrades + - htop + - iftop + - iotop + - neovim + - tmux + - git diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml new file mode 100644 index 0000000..450d5dc --- /dev/null +++ b/roles/docker/defaults/main.yml @@ -0,0 +1,7 @@ +--- +# Docker Compose options. +docker_old_compose_path: /usr/local/bin/docker-compose + +# Information about the old repository entry. +docker_apt_release_channel: stable +docker_old_apt_repository: "deb https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}" diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml new file mode 100644 index 0000000..72f297a --- /dev/null +++ b/roles/docker/tasks/main.yml @@ -0,0 +1,42 @@ +--- +- name: Ensure old versions of docker are not installed + package: + name: "{{ item }}" + state: absent + with_items: + - docker + - docker-engine + - docker-ce + +- name: Delete old docker-compose version if it's present + file: + path: "{{ docker_old_compose_path }}" + state: absent + + +- name: old docker apt key is no longer present + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 + state: absent + +- name: ensure docker repository is disabled + apt_repository: + repo: "{{ docker_old_apt_repository }}" + state: absent + update_cache: yes + +- name: Ensure docker is installed + package: + name: "{{ item }}" + state: present + with_items: + - docker.io + - docker-compose + +- name: Ensure docker is started and enabled at boot + service: + name: docker + state: started + enabled: yes + diff --git a/roles/python-base/tasks/main.yml b/roles/python-base/tasks/main.yml new file mode 100644 index 0000000..d9b8cc5 --- /dev/null +++ b/roles/python-base/tasks/main.yml @@ -0,0 +1,19 @@ +--- +# Some of the tasks below use 'raw', as more abstracted tasks such as 'apt' +# or 'shell' require python to be already installed. This can not be +# guaranteed at this point, so we will use raw until we installed all the +# necessary stuff. + +# first update the apt cache. +- name: "repositories are up to date" + raw: "apt-get update" + changed_when: False + +# install all requirements for ansible +- name: "python is installed" + raw: "apt-get --yes install python python-apt" + changed_when: False + +# At this point we can use the extra functionality from the installed +# libraries and no longer need to use 'raw'. +# ----- below this line, everything is allowed :) -----