Skip to content

Commit

Permalink
Add packages tasks to system role
Browse files Browse the repository at this point in the history
  • Loading branch information
egvimo committed Feb 14, 2021
1 parent 5df6ab5 commit df8580e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 3 deletions.
10 changes: 10 additions & 0 deletions molecule/system/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@
- name: Include role
include_role:
name: system

- name: Include role
include_role:
name: system
vars:
system_packages_to_remove:
- git
- gnupg
system_packages_to_install:
- screen
1 change: 1 addition & 0 deletions molecule/system/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ platforms:
image: ubuntu:latest
provisioner:
name: ansible
prepare: prepare.yml
env:
ANSIBLE_ROLES_PATH: ${MOLECULE_PROJECT_DIRECTORY}/roles
verifier:
Expand Down
12 changes: 12 additions & 0 deletions molecule/system/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Prepare
hosts: all
gather_facts: False
tasks:
- name: Install dependencies
ansible.builtin.apt:
pkg:
- git
- gnupg
update_cache: yes
state: present
8 changes: 5 additions & 3 deletions roles/system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ Ansible role to perform general system related tasks like updateing or installin

## Role Variables

| Variable | Default value | Description |
| -------- | ------------- | ----------- |
| - | - | - |
| Variable | Default value | Description |
| -------------------------- | ------------- | ------------------- |
| system_packages_to_remove | [] | Packages to remove |
| system_packages_to_install | [] | Packages to install |

## Tags

- `system`
- `system_update`
- `system_packages`
2 changes: 2 additions & 0 deletions roles/system/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
---
system_packages_to_remove: []
system_packages_to_install: []
1 change: 1 addition & 0 deletions roles/system/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- block:
- import_tasks: update.yml
- import_tasks: packages.yml
tags: system
13 changes: 13 additions & 0 deletions roles/system/tasks/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- block:
- name: Remove packages
apt:
pkg: "{{ system_packages_to_remove }}"
state: absent

- name: Install packages
apt:
pkg: "{{ system_packages_to_install }}"
state: present
become: yes
tags: system_packages

0 comments on commit df8580e

Please sign in to comment.