From 4b1403be219868d8892fddb3454584cc33b82cdc Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Sun, 13 Nov 2022 23:58:16 +0100 Subject: [PATCH] feat: initial commit Signed-off-by: Louis Vallat --- .ansible-lint | 3 +++ .gitignore | 3 +++ ansible.cfg | 14 ++++++++++++++ inventory.example.yaml | 8 ++++++++ playbook.yaml | 11 +++++++++++ roles/bpytop/tasks/main.yaml | 7 +++++++ roles/clean/tasks/main.yaml | 6 ++++++ roles/ctop/tasks/main.yaml | 27 +++++++++++++++++++++++++++ roles/docker/tasks/main.yaml | 30 ++++++++++++++++++++++++++++++ roles/softwares/tasks/main.yaml | 12 ++++++++++++ roles/system/tasks/main.yaml | 23 +++++++++++++++++++++++ 11 files changed, 144 insertions(+) create mode 100644 .ansible-lint create mode 100644 .gitignore create mode 100644 ansible.cfg create mode 100644 inventory.example.yaml create mode 100644 playbook.yaml create mode 100644 roles/bpytop/tasks/main.yaml create mode 100644 roles/clean/tasks/main.yaml create mode 100644 roles/ctop/tasks/main.yaml create mode 100644 roles/docker/tasks/main.yaml create mode 100644 roles/softwares/tasks/main.yaml create mode 100644 roles/system/tasks/main.yaml diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..42da3bd --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,3 @@ +--- +skip_list: + - package-latest diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5cfeab4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vscode/ +.fact_cache/ +inventory.yaml \ No newline at end of file diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..d1cb1be --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,14 @@ +[defaults] +INVENTORY = ./invetory.yaml +ansible_python_interpreter=/usr/bin/python3 +timeout=30 +gathering = smart +fact_caching = jsonfile +fact_caching_connection = .fact_cache +fact_caching_timeout = 43200 +hash_behaviour = merge +forks = 32 +nocows=1 + +[ssh_connection] +pipelining = True \ No newline at end of file diff --git a/inventory.example.yaml b/inventory.example.yaml new file mode 100644 index 0000000..258028b --- /dev/null +++ b/inventory.example.yaml @@ -0,0 +1,8 @@ +all: + hosts: + children: + : + hosts: + : + ansible_user: + ansible_ssh_private_key_file: diff --git a/playbook.yaml b/playbook.yaml new file mode 100644 index 0000000..3e73772 --- /dev/null +++ b/playbook.yaml @@ -0,0 +1,11 @@ +--- +- name: "Update/upgrade debian and install neovim" + hosts: prodservers + tags: debian + roles: + - system + - softwares + - bpytop + - docker + - ctop + - clean diff --git a/roles/bpytop/tasks/main.yaml b/roles/bpytop/tasks/main.yaml new file mode 100644 index 0000000..f2d7ef4 --- /dev/null +++ b/roles/bpytop/tasks/main.yaml @@ -0,0 +1,7 @@ +--- +- name: Install bpytop package from official repository + ansible.builtin.apt: + pkg: + - bpytop + state: latest + update_cache: true diff --git a/roles/clean/tasks/main.yaml b/roles/clean/tasks/main.yaml new file mode 100644 index 0000000..6a8de20 --- /dev/null +++ b/roles/clean/tasks/main.yaml @@ -0,0 +1,6 @@ +--- +- name: Update and upgrade packages just in case we missed some. + ansible.builtin.apt: + update_cache: true + upgrade: true + autoremove: true diff --git a/roles/ctop/tasks/main.yaml b/roles/ctop/tasks/main.yaml new file mode 100644 index 0000000..838cc06 --- /dev/null +++ b/roles/ctop/tasks/main.yaml @@ -0,0 +1,27 @@ +--- +- name: Install required system packages + ansible.builtin.apt: + pkg: + - apt-transport-https + - ca-certificates + - gnupg + - curl + state: latest + update_cache: true + +- name: Add ctop GPG apt key + ansible.builtin.apt_key: + url: https://azlux.fr/repo.gpg.key + state: present + +- name: Add ctop repository + ansible.builtin.apt_repository: + repo: deb http://packages.azlux.fr/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} main + state: present + +- name: Install ctop package + ansible.builtin.apt: + pkg: + - docker-ctop + state: latest + update_cache: true diff --git a/roles/docker/tasks/main.yaml b/roles/docker/tasks/main.yaml new file mode 100644 index 0000000..d0fe70a --- /dev/null +++ b/roles/docker/tasks/main.yaml @@ -0,0 +1,30 @@ +--- +- name: Install required system packages + ansible.builtin.apt: + pkg: + - apt-transport-https + - ca-certificates + - gnupg + - curl + state: latest + update_cache: true + +- name: Add Docker GPG apt key + ansible.builtin.apt_key: + url: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg + state: present + +- name: Add Docker repository + ansible.builtin.apt_repository: + repo: deb https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable + state: present + +- name: Install docker packages + ansible.builtin.apt: + pkg: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-compose-plugin + state: latest + update_cache: true diff --git a/roles/softwares/tasks/main.yaml b/roles/softwares/tasks/main.yaml new file mode 100644 index 0000000..af803a6 --- /dev/null +++ b/roles/softwares/tasks/main.yaml @@ -0,0 +1,12 @@ +--- +- name: Install neovim + ansible.builtin.apt: + name: neovim + state: latest + update_cache: true + +- name: Install htop + ansible.builtin.apt: + name: htop + state: latest + update_cache: true diff --git a/roles/system/tasks/main.yaml b/roles/system/tasks/main.yaml new file mode 100644 index 0000000..1301e2e --- /dev/null +++ b/roles/system/tasks/main.yaml @@ -0,0 +1,23 @@ +--- +- name: Update and upgrade packages + ansible.builtin.apt: + update_cache: true + upgrade: true + autoremove: true + +- name: Check if reboot required + ansible.builtin.stat: + path: /var/run/reboot-required + register: reboot_required_file + +- name: Reboot if required + ansible.builtin.reboot: + msg: Rebooting due to a kernel update + when: reboot_required_file.stat.exists + +- name: Disable cron e-mail notifications + ansible.builtin.cron: + name: MAILTO + user: root + env: true + job: ""