Skip to content

Commit

Permalink
add a new rocky linux file
Browse files Browse the repository at this point in the history
the common applications differ on RHEL based vms and Ubuntu vms. Create
a new common package variable to allow similar software installs. (where
possible)
add better tests
  • Loading branch information
kayiwa committed Nov 8, 2024
1 parent 4761cc8 commit bfda5c0
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 63 deletions.
19 changes: 18 additions & 1 deletion roles/common/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ duf_version: "0.8.1"
dust_version: "0.9.0"
fd_find_version: "9.0.0"
configured_dependencies: []
common_packages:
common_ubuntu_packages:
- acl
- build-essential
- curl
Expand All @@ -26,3 +26,20 @@ common_packages:
- wget
- zip
- zlib1g-dev
common_rhel_packages:
- curl
- "@Development tools"
- git
- htop
- jq
- libacl.x86_64
- libyaml-devel
- openssl-libs
- python3-devel
- python3-pip
- tmux
- tree
- unzip
- vim
- wget
- zip
45 changes: 23 additions & 22 deletions roles/common/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@
hosts: all
gather_facts: false
tasks:
- name: check common package status
ansible.builtin.apt:
name: "{{ item }}"
state: present
check_mode: true
register: pkg_status
loop:
- acl
- htop
- python3-apt
- build-essential
- curl
- git
- unzip
- zip
- tmux
- vim
- silversearcher-ag
- name: Common | Verify tmux.conf exists
ansible.builtin.stat:
path: /etc/tmux.conf
register: tmux_conf

- name: test packages are installed
ansible.builtin.assert:
that:
- not pkg_status.changed
- name: Common | Assert tmux.conf exists
ansible.builtin.assert:
that:
- tmux_conf.stat.exists

- name: Common | Verify vimrc exists
ansible.builtin.stat:
path: /etc/vim/vimrc.local
register: vimrc

- name: Common | Assert vimrc exists
ansible.builtin.assert:
that:
- vimrc.stat.exists

- name: Common | Verify common Ubuntu packages are installed
ansible.builtin.apt:
name: "{{ common_ubuntu_packages }}"
state: present
57 changes: 17 additions & 40 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,14 @@
"ansible_hostname not in inventory_hostname"
tags: "update_hostname"

- name: Common | Add apt HTTPS capabilities.
ansible.builtin.package:
name: "{{ item }}"
state: present
- name: Common | Install Common packages
ansible.builtin.include_tasks: "{{ item }}"
loop:
- ca-certificates
- apt-transport-https
- ubuntu.yml
- rockylinux.yml
when:
- ansible_os_family == "Debian"

- name: Common | install snapd
ansible.builtin.package:
name: "{{ item }}"
state: present
loop:
- snapd
when: running_on_server

- name: Common | Install procs
community.general.snap:
name:
- procs
when: running_on_server

- name: Common | install building software and build essentials
ansible.builtin.package:
name: "{{ item }}"
state: present
update_cache: true
with_items: "{{ common_packages }}"
- item is defined
- item is not none

- name: Common | copy tmux.conf
ansible.builtin.template:
Expand Down Expand Up @@ -79,15 +57,11 @@
state: present

- name: Common | install duf
ansible.builtin.apt:
deb: "{{ duf_url }}/v{{ duf_version }}/duf_{{ duf_version }}_linux_amd64.deb"
register: duf_repo
retries: 3
delay: 60
until: duf_repo is succeeded
ansible.builtin.package:
state: present
when:
- running_on_server
- ansible_os_family == "Debian"
- ansible_distribution == "Ubuntu"
- ansible_distribution_release == "jammy"

- name: Common | install dust
ansible.builtin.apt:
Expand All @@ -97,9 +71,12 @@
- ansible_os_family == "Debian"

- name: Common | install fdfind
ansible.builtin.apt:
deb: "{{ fd_find_url }}/v{{ fd_find_version }}/fd_{{ fd_find_version }}_amd64.deb"
when: running_on_server
ansible.builtin.package:
name: fd-find
state: present
when:
- ansible_os_family == "Debian"
- running_on_server

- name: Common | install plocate (jammy)
ansible.builtin.apt:
Expand All @@ -109,5 +86,5 @@
- ansible_distribution =="Ubuntu" and ansible_distribution_release == "jammy"

- name: Common | install vector, but not in testing
include_tasks: vector.yml
ansible.builtin.include_tasks: vector.yml
when: running_on_server
9 changes: 9 additions & 0 deletions roles/common/tasks/rockylinux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Install common packages for Rocky Linux
ansible.builtin.package:
name: "{{ item }}"
state: present
use: dnf
loop: "{{ common_rhel_packages }}"
when:
- ansible_os_family == "RedHat"
7 changes: 7 additions & 0 deletions roles/common/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Install common packages for Ubuntu
ansible.builtin.package:
name: "{{ common_ubuntu_packages }}"
state: present
when:
- ansible_os_family == "Debian"

0 comments on commit bfda5c0

Please sign in to comment.