Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add centos support #4

Merged
merged 1 commit into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This is an Ansible collection that installs and then configures various system.
- [apt_keys](roles/apt_keys/README.md)
- [apt_packages](roles/apt_packages/README.md)
- [apt_repositories](roles/apt_repositories/README.md)
- [dnf_packages](roles/dnf_packages/README.md)
- [logrotate](roles/logrotate/README.md)
- [maintenance](roles/maintenance/README.md)
- [netplan](roles/netplan/README.md)
Expand Down
5 changes: 5 additions & 0 deletions roles/dnf_packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ansible Role: arillso.system.dnf_packages

## Description

The role installs different packages on the dnf system.
8 changes: 8 additions & 0 deletions roles/dnf_packages/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

dnf_packages_allow_downgrade: false
dnf_packages_install_recommends: false
dnf_packages_lock_timeout: 60
dnf_packages_purge: true
dnf_packages_state: present
dnf_packages: []
20 changes: 20 additions & 0 deletions roles/dnf_packages/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---

galaxy_info:
description: The role installs different packages on the dnf system.
author: "arillso (@arillso)"
license: MIT
min_ansible_version: "2.11"
platforms:
- name: Centos
versions:
- all


galaxy_tags:
- package
- packages
- dnf
- yum

dependencies: []
34 changes: 34 additions & 0 deletions roles/dnf_packages/tasks/install_dnf_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---

- name: ensure {{ dnf_package_name | default(omit) }} dnf package
become: true
ansible.builtin.dnf:
allow_downgrade: "{{ dnf_package_allow_downgrade | default(omit) }}"
allowerasing: "{{ dnf_package_allowerasing | default(omit) }}"
autoremove: "{{ dnf_package_autoremove | default(omit) }}"
bugfix: "{{ dnf_package_bugfix | default(omit) }}"
cacheonly: "{{ dnf_package_cacheonly | default(omit) }}"
conf_file: "{{ dnf_package_conf_file | default(omit) }}"
disable_gpg_check: "{{ dnf_package_disable_gpg_check | default(omit) }}"
disable_plugin: "{{ dnf_package_disable_plugin | default(omit) }}"
disablerepo: "{{ dnf_package_disablerepo | default(omit) }}"
download_dir: "{{ dnf_package_download_dir | default(omit) }}"
download_only: "{{ dnf_package_download_only | default(omit) }}"
enable_plugin: "{{ dnf_package_enable_plugin | default(omit) }}"
enablerepo: "{{ dnf_package_enablerepo | default(omit) }}"
exclude: "{{ dnf_package_exclude | default(omit) }}"
install_repoquery: "{{ dnf_package_install_repoquery | default(omit) }}"
install_weak_deps: "{{ dnf_package_install_weak_deps | default(omit) }}"
installroot: "{{ dnf_package_installroot | default(omit) }}"
list: "{{ dnf_package_list | default(omit) }}"
lock_timeout: "{{ dnf_package_lock_timeout | default(omit) }}"
name: "{% if dnf_package_version and dnf_package_version > 0 %}{{ dnf_package_name }}={{ dnf_package_version }}{% else %}{{ dnf_package_name }}{% endif %}"
nobest: "{{ dnf_package_nobest | default(omit) }}"
releasever: "{{ dnf_package_releasever | default(omit) }}"
security: "{{ dnf_package_security | default(omit) }}"
skip_broken: "{{ dnf_package_skip_broken | default(omit) }}"
sslverify: "{{ dnf_package_sslverify | default(omit) }}"
state: "{{ dnf_package_state | default(omit) }}"
update_cache: "{{ dnf_package_update_cache | default(omit) }}"
update_only: "{{ dnf_package_update_only | default(omit) }}"
validate_certs: "{{ dnf_package_validate_certs | default(omit) }}"
39 changes: 39 additions & 0 deletions roles/dnf_packages/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---

- name: ensure dnf packages
ansible.builtin.include_tasks: install_dnf_package.yml
vars:
dnf_package_allow_downgrade: "{{ dnf_package.allow_downgrade | default(dnf_packages_allow_downgrade | default(omit)) }}"
dnf_package_allowerasing: "{{ dnf_package.allowerasing | default(dnf_packages_allowerasing | default(omit)) }}"
dnf_package_autoremove: "{{ dnf_package.autoremove | default(dnf_packages_autoremove | default(omit)) }}"
dnf_package_bugfix: "{{ dnf_package.bugfix | default(dnf_packages_bugfix | default(omit)) }}"
dnf_package_cacheonly: "{{ dnf_package.cacheonly | default(dnf_packages_cacheonly | default(omit)) }}"
dnf_package_conf_file: "{{ dnf_package.conf_file | default(dnf_packages_conf_file | default(omit)) }}"
dnf_package_disable_gpg_check: "{{ dnf_package.disable_gpg_check | default(dnf_packages_disable_gpg_check | default(omit)) }}"
dnf_package_disable_plugin: "{{ dnf_package.disable_plugin | default(dnf_packages_disable_plugin | default(omit)) }}"
dnf_package_disablerepo: "{{ dnf_package.disablerepo | default(dnf_packages_disablerepo | default(omit)) }}"
dnf_package_download_dir: "{{ dnf_package.download_dir | default(dnf_packages_download_dir | default(omit)) }}"
dnf_package_download_only: "{{ dnf_package.download_only | default(dnf_packages_download_only | default(omit)) }}"
dnf_package_enable_plugin: "{{ dnf_package.enable_plugin | default(dnf_packages_enable_plugin | default(omit)) }}"
dnf_package_enablerepo: "{{ dnf_package.enablerepo | default(omit) }}"
dnf_package_exclude: "{{ dnf_package.exclude | default(omit) }}"
dnf_package_install_repoquery: "{{ dnf_package.install_repoquery | default(omit) }}"
dnf_package_install_weak_deps: "{{ dnf_package.install_weak_deps | default(omit) }}"
dnf_package_installroot: "{{ dnf_package.installroot | default(omit) }}"
dnf_package_list: "{{ dnf_package.list | default(omit) }}"
dnf_package_lock_timeout: "{{ dnf_package.lock_timeout | default(dnf_packages_lock_timeout | default(omit)) }}"
dnf_package_name: "{{ dnf_package.name }}"
dnf_package_version: "{{ dnf_package.version | default('') }}"
dnf_package_nobest: "{{ dnf_package.nobest | default(dnf_packages_nobest| default(omit)) }}"
dnf_package_releasever: "{{ dnf_package.releasever | default(dnf_packages_releasever | default(omit)) }}"
dnf_package_security: "{{ dnf_package.security | default(dnf_packages_security | default(omit)) }}"
dnf_package_skip_broken: "{{ dnf_package.skip_broken | default(dnf_packages_skip_broken | default(omit)) }}"
dnf_package_sslverify: "{{ dnf_package.sslverify | default(dnf_packages_sslverify | default(omit)) }}"
dnf_package_state: "{{ dnf_package.state | default('present') }}"
dnf_package_update_cache: "{{ dnf_package.update_cache | default(dnf_packages_update_cache | default(omit)) }}"
dnf_package_update_only: "{{ dnf_package.update_only | default(dnf_packages_update_only | default(omit)) }}"
dnf_package_validate_certs: "{{ dnf_package.validate_certs | default(dnf_packages_validate_certs | default(omit)) }}"
loop: "{{ dnf_packages }}"
loop_control:
label: "{{ dnf_package_name }}"
loop_var: dnf_package
1 change: 1 addition & 0 deletions roles/logrotate/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ logrotate_compress: true
# User/Group for rotated log files (Loaded by OS-Specific vars if found, or and can be set manually)
logrotate_user: "{{ _logrotate_user[ansible_distribution] | default(_logrotate_user['default'] ) }}"
logrotate_group: "{{ _logrotate_group[ansible_distribution] | default(_logrotate_group['default'] ) }}"
logrotate_dateext: "{{ _logrotate_dateext[ansible_distribution] | default(_logrotate_dateext['default'] ) }}"

logrotate_entries: []
12 changes: 12 additions & 0 deletions roles/logrotate/tasks/install_logrotate_centos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: Run arillso dnf Package
ansible.builtin.include_role:
name: arillso.system.dnf_packages
tasks_from: install_dnf_package
loop: "{{ logrotate_packages }}"
loop_control:
loop_var: logrotate_package
vars:
dnf_package_name: "{{ logrotate_package.name }}"
dnf_package_version: "{{ logrotate_package.version | default('') }}"
7 changes: 7 additions & 0 deletions roles/logrotate/templates/etc/logrotate.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ rotate {{ logrotate_keep }}
# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
{% if logrotate_dateext %}
dateext
{% else %}
#dateext
{% endif %}

# uncomment this if you want your log files compressed
{% if logrotate_compress %}
compress
Expand Down
6 changes: 6 additions & 0 deletions roles/logrotate/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ _logrotate_group:
default: root
Debian: adm
Ubuntu: adm

_logrotate_dateext:
default: false
Debian: false
Ubuntu: false
CentOS: true
3 changes: 3 additions & 0 deletions roles/packages/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

packages: []
7 changes: 7 additions & 0 deletions roles/packages/tasks/install_package_centos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

- name: Run arillso dnf Package
ansible.builtin.include_role:
name: arillso.system.dnf_packages
vars:
dnf_packages: "{{ packages }}"
2 changes: 1 addition & 1 deletion roles/packages/tasks/install_package_debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ansible.builtin.include_role:
name: arillso.system.apt_packages
tasks_from: install_apt_package
loop: "{{ netplan_packages }}"
loop: "{{ packages }}"
loop_control:
loop_var: apt_package
vars:
Expand Down
15 changes: 15 additions & 0 deletions roles/packages/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
---

- name: include distribution tasks
ansible.builtin.include_tasks: "{{ lookup('ansible.builtin.first_found', params) }}"
vars:
distribution: "{{ ansible_distribution }}"
distribution_version: "{{ ansible_distribution_version }}"
distribution_major_version: "{{ ansible_distribution_major_version }}"
params:
files:
- "install_package_{{ distribution | lower }}_{{ distribution_version | lower }}.yml"
- "install_package_{{ distribution | lower }}_{{ distribution_major_version | lower }}.yml"
- "install_package_{{ distribution | lower }}.yml"
- "install_package_{{ ansible_os_family | lower }}.yml"
- "install_package_{{ ansible_system | lower }}.yml"
- "defaults.yml"
1 change: 1 addition & 0 deletions roles/sysctl/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ sysctl_entries_ignoreerrors: false
sysctl_entries_reload: true
sysctl_entries_sysctl_file: "/etc/sysctl.conf"
sysctl_entries_sysctl_set: false
sysctl_entries: []