From 5b89cfced56b2f679e3039d92ce297aeb25e7b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Thu, 13 Jan 2022 00:24:36 +0100 Subject: [PATCH] Add common role --- project/main.yml | 4 ++++ project/roles/common/tasks/main.yml | 3 +++ project/roles/common/tasks/packages.yml | 16 ++++++++++++++++ project/roles/common/tasks/packages_debian.yml | 6 ++++++ project/roles/common/tasks/packages_redhat.yml | 6 ++++++ 5 files changed, 35 insertions(+) create mode 100644 project/roles/common/tasks/main.yml create mode 100644 project/roles/common/tasks/packages.yml create mode 100644 project/roles/common/tasks/packages_debian.yml create mode 100644 project/roles/common/tasks/packages_redhat.yml diff --git a/project/main.yml b/project/main.yml index 5d24fd2..fa1afe3 100644 --- a/project/main.yml +++ b/project/main.yml @@ -4,6 +4,10 @@ - name: Ping hosts ansible.builtin.ping: +- hosts: all + roles: + - common + - hosts: docker2.t-juice.club roles: - vault diff --git a/project/roles/common/tasks/main.yml b/project/roles/common/tasks/main.yml new file mode 100644 index 0000000..68e68e7 --- /dev/null +++ b/project/roles/common/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: Ensure packages are installed + import_tasks: packages.yml diff --git a/project/roles/common/tasks/packages.yml b/project/roles/common/tasks/packages.yml new file mode 100644 index 0000000..bde8318 --- /dev/null +++ b/project/roles/common/tasks/packages.yml @@ -0,0 +1,16 @@ +--- +- name: Ensure common packages are installed + ansible.builtin.package: + name: + - zsh + - htop + - xfsprogs + - iotop + +- name: Ensure debian-specific packages are installed + import_tasks: packages_debian.yml + when: ansible_facts['os-family']|lower == 'debian' + +- name: Ensure rhel-specific packages are installed + import_tasks: packages_redhat.yml + when: ansible_facts['os-family']|lower == 'redhat' diff --git a/project/roles/common/tasks/packages_debian.yml b/project/roles/common/tasks/packages_debian.yml new file mode 100644 index 0000000..ccb3c81 --- /dev/null +++ b/project/roles/common/tasks/packages_debian.yml @@ -0,0 +1,6 @@ +--- +- name: Ensure packages are installed + ansible.builtin.package: + name: + - vim + - xfsprogs \ No newline at end of file diff --git a/project/roles/common/tasks/packages_redhat.yml b/project/roles/common/tasks/packages_redhat.yml new file mode 100644 index 0000000..40b40cc --- /dev/null +++ b/project/roles/common/tasks/packages_redhat.yml @@ -0,0 +1,6 @@ +--- +- name: Ensure packages are installed + ansible.builtin.package: + name: + - vim-enhanced + - yum-cron