Initial release version to AAP #5
@ -3,3 +3,4 @@ skip_list:
|
||||
- yaml[empty-lines]
|
||||
- yaml[line-length]
|
||||
- no-changed-when
|
||||
- galaxy[no-changelog]
|
||||
|
3
.drone.env
Normal file
3
.drone.env
Normal file
@ -0,0 +1,3 @@
|
||||
export ANSIBLE_LINT_EXCLUSION="--exclude .gitea"
|
||||
export ANSIBLE_INVENTORY="-i 127.0.0.1, --connection=local"
|
||||
export ANSIBLE_PLAYBOOK="baseos.yml"
|
111
.drone.yml
Normal file
111
.drone.yml
Normal file
@ -0,0 +1,111 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: CentOS_9-Ansible-Pipeline
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- main
|
||||
event: [push]
|
||||
|
||||
steps:
|
||||
- name: ansible_environment_verify
|
||||
image: gitea.thezengarden.net/podman/ansible-dev/centos9:release
|
||||
commands:
|
||||
- . ./.drone.env
|
||||
- env
|
||||
- git log -1
|
||||
- ansible --version
|
||||
- ansible-lint --version
|
||||
|
||||
- name: ansible_lint
|
||||
image: gitea.thezengarden.net/podman/ansible-dev/centos9:release
|
||||
commands:
|
||||
- . ./.drone.env
|
||||
- ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION
|
||||
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Fedora_39-Ansible-Pipeline
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- main
|
||||
event: [push]
|
||||
|
||||
steps:
|
||||
- name: ansible_environment_verify
|
||||
image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release
|
||||
commands:
|
||||
- . ./.drone.env
|
||||
- env
|
||||
- git log -1
|
||||
- ansible --version
|
||||
- ansible-lint --version
|
||||
|
||||
- name: ansible_lint
|
||||
image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release
|
||||
commands:
|
||||
- . ./.drone.env
|
||||
- ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION
|
||||
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Debian_11-Ansible-Pipeline
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- main
|
||||
event: [push]
|
||||
|
||||
steps:
|
||||
- name: ansible_environment_verify
|
||||
image: gitea.thezengarden.net/podman/ansible-dev/debian11:release
|
||||
commands:
|
||||
- . ./.drone.env
|
||||
- env
|
||||
- git log -1
|
||||
- ansible --version
|
||||
- ansible-lint --version
|
||||
|
||||
- name: ansible_lint
|
||||
image: gitea.thezengarden.net/podman/ansible-dev/debian11:release
|
||||
commands:
|
||||
- . ./.drone.env
|
||||
- ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION
|
||||
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Debian_12-Ansible-Pipeline
|
||||
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- main
|
||||
event: [push]
|
||||
|
||||
steps:
|
||||
- name: ansible_environment_verify
|
||||
image: gitea.thezengarden.net/podman/ansible-dev/debian12:release
|
||||
commands:
|
||||
- . ./.drone.env
|
||||
- env
|
||||
- git log -1
|
||||
- ansible --version
|
||||
- ansible-lint --version
|
||||
|
||||
- name: ansible_lint
|
||||
image: gitea.thezengarden.net/podman/ansible-dev/debian12:release
|
||||
commands:
|
||||
- . ./.drone.env
|
||||
- ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION
|
30
.gitea/workflows/ansible-test.yml
Normal file
30
.gitea/workflows/ansible-test.yml
Normal file
@ -0,0 +1,30 @@
|
||||
name: Ansible Code Pipeline
|
||||
run-name: ${{ gitea.actor }} is running Ansible Code Pipeline
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- testing
|
||||
|
||||
jobs:
|
||||
Ansible-Development-Pipeline:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ansible-dev-centos9, ansible-dev-fedora39, ansible-dev-debian11, ansible-dev-debian12 ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Ansible Environment Verify
|
||||
run: |
|
||||
. ./.drone.env
|
||||
env
|
||||
git log -1
|
||||
ansible --version
|
||||
ansible-lint --version
|
||||
|
||||
- name: Run Ansible-Lint
|
||||
run: |
|
||||
. ./.drone.env
|
||||
ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION
|
2
ansible.cfg
Normal file
2
ansible.cfg
Normal file
@ -0,0 +1,2 @@
|
||||
[defaults]
|
||||
roles_path = roles
|
@ -8,7 +8,7 @@ namespace: jchristianh
|
||||
name: baseos
|
||||
|
||||
# The version of the collection. Must be compatible with semantic versioning
|
||||
version: 1.0.17
|
||||
version: 1.0.20
|
||||
|
||||
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
|
||||
readme: README.md
|
||||
@ -34,7 +34,8 @@ license_file: 'LICENSE'
|
||||
|
||||
# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
|
||||
# requirements as 'namespace' and 'name'
|
||||
tags: []
|
||||
tags:
|
||||
- linux
|
||||
|
||||
# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
|
||||
# collection label 'namespace.name'. The value is a version range
|
||||
|
@ -1,2 +1,2 @@
|
||||
---
|
||||
requires_ansible: ">=2.14"
|
||||
requires_ansible: ">=2.15.0"
|
||||
|
@ -1,10 +0,0 @@
|
||||
---
|
||||
__project_author : Chris Hammer
|
||||
__project_email : chris@thezengarden.net
|
||||
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
|
||||
|
||||
|
||||
__template_header : The Zen Garden
|
||||
|
||||
|
||||
...
|
@ -2,18 +2,18 @@
|
||||
- name: Include distribution specific variables or include defaults
|
||||
block:
|
||||
- name: Include distribution specific variables
|
||||
include_vars:
|
||||
ansible.builtin.include_vars:
|
||||
file: "{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}.yml"
|
||||
|
||||
|
||||
rescue:
|
||||
- name: Non-supported distribution; using default package set
|
||||
include_vars:
|
||||
file: __default_packages.yml
|
||||
ansible.builtin.include_vars:
|
||||
file: default_packages.yml
|
||||
|
||||
|
||||
- name: Install EPEL for CentOS hosts - Required for some of our packages
|
||||
package:
|
||||
- name: Install EPEL for CentOS hosts - Required for some packages
|
||||
ansible.builtin.package:
|
||||
name : epel-release
|
||||
state : present
|
||||
when:
|
||||
@ -21,8 +21,8 @@
|
||||
|
||||
|
||||
- name: Install package set
|
||||
package:
|
||||
name : "{{ __base_packages }}"
|
||||
ansible.builtin.package:
|
||||
name : "{{ base_packages_package_set }}"
|
||||
state : present
|
||||
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- base_packages
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
__base_packages:
|
||||
base_packages_package_set:
|
||||
- bc
|
||||
- bind-utils
|
||||
- bzip2
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
__base_packages:
|
||||
base_packages_package_set:
|
||||
- bc
|
||||
- bind-utils
|
||||
- bzip2
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
__base_packages:
|
||||
base_packages_package_set:
|
||||
- bc
|
||||
- bind-utils
|
||||
- bzip2
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
__base_packages:
|
||||
base_packages_package_set:
|
||||
- bc
|
||||
- bind9utils
|
||||
- bzip2
|
||||
|
@ -5,7 +5,7 @@
|
||||
# Please adjust accordingly, or include a vars file matching the pattern:
|
||||
# <ansible_distribution>_<ansible_distribution_major_version>.yml
|
||||
|
||||
__base_packages:
|
||||
base_packages_package_set:
|
||||
- bc
|
||||
- bzip2
|
||||
- file
|
@ -1,2 +0,0 @@
|
||||
---
|
||||
# vars file for base_packages
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
- name: Deploy .bashrc
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src : files/bashrc
|
||||
dest : /root/.bashrc
|
||||
mode : 0640
|
||||
mode : "0640"
|
||||
|
||||
|
||||
...
|
||||
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- bashrc
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- default_services
|
@ -1,15 +1,15 @@
|
||||
---
|
||||
__project_author : Chris Hammer
|
||||
__project_email : chris@thezengarden.net
|
||||
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
|
||||
etc_hosts_project_author : Chris Hammer
|
||||
etc_hosts_project_email : chris@thezengarden.net
|
||||
etc_hosts_project_repo : https://github.com/jchristianh-ansible-collections/baseos
|
||||
|
||||
|
||||
__template_header : The Zen Garden
|
||||
etc_hosts_template_header : The Zen Garden
|
||||
|
||||
|
||||
__etc_hosts_file : /etc/hosts
|
||||
__etc_hosts_version : 1.0.0
|
||||
__etc_hosts_revision : 22314
|
||||
etc_hosts_etc_hosts_file : /etc/hosts
|
||||
etc_hosts_etc_hosts_version : 1.0.1
|
||||
etc_hosts_etc_hosts_revision : 231216
|
||||
|
||||
|
||||
...
|
||||
|
@ -1,16 +1,16 @@
|
||||
---
|
||||
- name: Set etc_hosts_file if running in Docker
|
||||
set_fact:
|
||||
__etc_hosts_file: "{{ __etc_hosts_file }}.docker"
|
||||
- name: Set etc_hosts_etc_hosts_file if running in Docker
|
||||
ansible.builtin.set_fact:
|
||||
etc_hosts_etc_hosts_file: "{{ etc_hosts_etc_hosts_file }}.docker"
|
||||
when:
|
||||
- ansible_virtualization_type | regex_search("docker|podman|container")
|
||||
|
||||
|
||||
- name: Deploy {{ __etc_hosts_file }}
|
||||
template:
|
||||
- name: Deploy {{ etc_hosts_etc_hosts_file }}
|
||||
ansible.builtin.template:
|
||||
src: templates/etc_hosts.j2
|
||||
dest: "{{ __etc_hosts_file }}"
|
||||
mode: 0644
|
||||
dest: "{{ etc_hosts_etc_hosts_file }}"
|
||||
mode: "0644"
|
||||
|
||||
|
||||
...
|
||||
|
@ -1,11 +1,11 @@
|
||||
###############################################
|
||||
# {{ __template_header }}
|
||||
# {{ etc_hosts_template_header }}
|
||||
###############################################
|
||||
#
|
||||
# Configuration : {{ __etc_hosts_file }}
|
||||
# Template Version : {{ __etc_hosts_version}}-{{ __etc_hosts_revision }}
|
||||
# Configuration : {{ etc_hosts_etc_hosts_file }}
|
||||
# Template Version : {{ etc_hosts_etc_hosts_version }}-{{ etc_hosts_etc_hosts_revision }}
|
||||
#
|
||||
# {{ __project_author }} ({{ __project_email }})
|
||||
# {{ etc_hosts_project_author }} ({{ etc_hosts_project_email }})
|
||||
###############################################
|
||||
|
||||
|
||||
@ -20,10 +20,10 @@
|
||||
{{ ansible_default_ipv4.address | default('127.0.0.1') }} {{ ansible_fqdn }} {{ ansible_hostname }} {{ inventory_hostname }}
|
||||
|
||||
|
||||
{% if custom_hosts is defined and custom_hosts != '' %}
|
||||
{% if etc_hosts_custom_hosts is defined and etc_hosts_custom_hosts != '' %}
|
||||
# CUSTOM HOSTS:
|
||||
#############################################
|
||||
{% for item in custom_hosts %}
|
||||
{% for item in etc_hosts_custom_hosts %}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- etc_hosts
|
@ -1,46 +1,46 @@
|
||||
---
|
||||
- name: restart_syslog_centos_7
|
||||
service:
|
||||
- name: Restart_syslog_centos_7
|
||||
ansible.builtin.service:
|
||||
name : rsyslog
|
||||
state : restarted
|
||||
|
||||
- name: restart_syslog_centos_8
|
||||
service:
|
||||
- name: Restart_syslog_centos_8
|
||||
ansible.builtin.service:
|
||||
name : syslog
|
||||
state : restarted
|
||||
|
||||
- name: restart_syslog_centos_9
|
||||
service:
|
||||
- name: Restart_syslog_centos_9
|
||||
ansible.builtin.service:
|
||||
name : rsyslog
|
||||
state : restarted
|
||||
|
||||
- name: restart_syslog_redhat_8
|
||||
service:
|
||||
- name: Restart_syslog_redhat_8
|
||||
ansible.builtin.service:
|
||||
name : rsyslog
|
||||
state : restarted
|
||||
|
||||
- name: restart_syslog_redhat_9
|
||||
service:
|
||||
- name: Restart_syslog_redhat_9
|
||||
ansible.builtin.service:
|
||||
name : rsyslog
|
||||
state : restarted
|
||||
|
||||
- name: restart_syslog_debian_11
|
||||
service:
|
||||
- name: Restart_syslog_debian_11
|
||||
ansible.builtin.service:
|
||||
name : rsyslog
|
||||
state : restarted
|
||||
|
||||
- name: restart_syslog_debian_12
|
||||
service:
|
||||
- name: Restart_syslog_debian_12
|
||||
ansible.builtin.service:
|
||||
name : rsyslog
|
||||
state : restarted
|
||||
|
||||
- name: restart_syslog_fedora_35
|
||||
service:
|
||||
- name: Restart_syslog_fedora_35
|
||||
ansible.builtin.service:
|
||||
name : rsyslog
|
||||
state : restarted
|
||||
|
||||
- name: restart_syslog_fedora_38
|
||||
service:
|
||||
- name: Restart_syslog_fedora_38
|
||||
ansible.builtin.service:
|
||||
name : rsyslog
|
||||
state : started
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
- name: Set hostname for host
|
||||
hostname:
|
||||
ansible.builtin.hostname:
|
||||
name: "{{ inventory_hostname }}"
|
||||
notify:
|
||||
- "restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
|
||||
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
|
||||
|
||||
|
||||
...
|
||||
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- hostname
|
@ -1,16 +1,5 @@
|
||||
---
|
||||
__project_author : Chris Hammer
|
||||
__project_email : chris@thezengarden.net
|
||||
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
|
||||
|
||||
|
||||
__template_header : The Zen Garden
|
||||
|
||||
|
||||
__motd_file : /etc/motd
|
||||
__motd_file_docker : /etc/motd
|
||||
__motd_version : 1.0.0
|
||||
__motd_revision : 22318
|
||||
motd_motd_file : /etc/motd
|
||||
|
||||
|
||||
...
|
||||
|
@ -1,27 +1,27 @@
|
||||
---
|
||||
- name: Set host IP address or set a default
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
host_ip : "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
|
||||
|
||||
|
||||
- name: Install Perl if needed
|
||||
package:
|
||||
ansible.builtin.package:
|
||||
name : perl
|
||||
state : present
|
||||
|
||||
|
||||
- name: Get system uptime from script
|
||||
script:
|
||||
ansible.builtin.script:
|
||||
cmd : "scripts/get_uptime.pl {{ ansible_uptime_seconds }}"
|
||||
register : node_uptime
|
||||
changed_when : false
|
||||
|
||||
|
||||
- name: Update MOTD
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src : templates/motd.j2
|
||||
dest : "{{ __motd_file }}"
|
||||
mode : 0644
|
||||
dest : "{{ motd_motd_file }}"
|
||||
mode : "0644"
|
||||
changed_when : false
|
||||
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- motd
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- node_status
|
@ -1,20 +1,19 @@
|
||||
---
|
||||
__project_author : Chris Hammer
|
||||
__project_email : chris@thezengarden.net
|
||||
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
|
||||
resolv_conf_project_author : Chris Hammer
|
||||
resolv_conf_project_email : chris@thezengarden.net
|
||||
resolv_conf_project_repo : https://github.com/jchristianh-ansible-collections/baseos
|
||||
|
||||
|
||||
__template_header : The Zen Garden
|
||||
resolv_conf_template_header : The Zen Garden
|
||||
|
||||
|
||||
__resolv_conf_file : /etc/resolv.conf
|
||||
__resolv_conf_file_docker : /etc/resolv.conf.docker
|
||||
__resolv_conf_version : 1.0.1
|
||||
__resolv_conf_revision : 221007
|
||||
resolv_conf_resolv_conf_file : /etc/resolv.conf
|
||||
resolv_conf_resolv_conf_version : 1.0.1
|
||||
resolv_conf_resolv_conf_revision : 221007
|
||||
|
||||
|
||||
__search_domain : thezengarden.net
|
||||
__nameservers :
|
||||
resolv_conf_search_domain : thezengarden.net
|
||||
resolv_conf_nameservers :
|
||||
- 10.10.10.55
|
||||
- 10.1.1.15
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
---
|
||||
- name: Set resolv_conf_file if running in Docker
|
||||
- name: Set resolv_conf_file if running in container
|
||||
ansible.builtin.set_fact:
|
||||
__resolv_conf_file: "{{ __resolv_conf_file_docker }}"
|
||||
resolv_conf_resolv_conf_file: "{{ resolv_conf_resolv_conf_file }}.docker"
|
||||
when:
|
||||
- ansible_virtualization_type | regex_search("docker|podman|container")
|
||||
|
||||
|
||||
- name: Deploy {{ __resolv_conf_file }}
|
||||
- name: Deploy {{ resolv_conf_resolv_conf_file }}
|
||||
ansible.builtin.template:
|
||||
src: templates/resolv_conf.j2
|
||||
dest: "{{ __resolv_conf_file }}"
|
||||
dest: "{{ resolv_conf_resolv_conf_file }}"
|
||||
mode: "0644"
|
||||
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
# {{ __template_header }}
|
||||
# {{ resolv_conf_template_header }}
|
||||
###############################################
|
||||
#
|
||||
# Configuration : {{ __resolv_conf_file }}
|
||||
# Template Version : {{ __resolv_conf_version}}-{{ __resolv_conf_revision }}
|
||||
# Configuration : {{ resolv_conf_resolv_conf_file }}
|
||||
# Template Version : {{ resolv_conf_resolv_conf_version }}-{{ resolv_conf_resolv_conf_revision }}
|
||||
#
|
||||
# {{ __project_author }} ({{ __project_email }})
|
||||
# {{ resolv_conf_project_author }} ({{ resolv_conf_project_email }})
|
||||
###############################################
|
||||
|
||||
|
||||
search {{ __search_domain }}
|
||||
{% for item in __nameservers %}
|
||||
search {{ resolv_conf_search_domain }}
|
||||
{% for item in resolv_conf_nameservers %}
|
||||
nameserver {{ item }}
|
||||
{% endfor %}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- resolv_conf
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
__project_author : Chris Hammer
|
||||
__project_email : chris@thezengarden.net
|
||||
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
|
||||
snmpd_conf_project_author : Chris Hammer
|
||||
snmpd_conf_project_email : chris@thezengarden.net
|
||||
snmpd_conf_project_repo : https://github.com/jchristianh-ansible-collections/baseos
|
||||
|
||||
|
||||
__template_header : The Zen Garden
|
||||
snmpd_conf_template_header : The Zen Garden
|
||||
|
||||
|
||||
__snmpd_conf_file : /etc/snmp/snmpd.conf
|
||||
__snmpd_conf_version : 1.0.1
|
||||
__snmpd_conf_revision : 231210
|
||||
snmpd_conf_snmpd_conf_file : /etc/snmp/snmpd.conf
|
||||
snmpd_conf_snmpd_conf_version : 1.0.1
|
||||
snmpd_conf_snmpd_conf_revision : 231210
|
||||
|
||||
|
||||
__snmp_pkg : net-snmp
|
||||
snmpd_conf_snmp_pkg : net-snmp
|
||||
|
||||
|
||||
__snmpd_location : 'Newport News, VA'
|
||||
__snmpd_contact_name : 'Chris Hammer'
|
||||
__snmpd_contact_email : '<chris@thezengarden.net>'
|
||||
snmpd_conf_snmpd_location : 'Newport News, VA'
|
||||
snmpd_conf_snmpd_contact_name : 'Chris Hammer'
|
||||
snmpd_conf_snmpd_contact_email : '<chris@thezengarden.net>'
|
||||
|
||||
|
||||
...
|
||||
|
@ -1,40 +1,35 @@
|
||||
---
|
||||
- name: Include distribution specific variables or include defaults
|
||||
block:
|
||||
- name: Include distribution specific variables
|
||||
include_vars:
|
||||
file: "{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}.yml"
|
||||
|
||||
|
||||
rescue:
|
||||
- name: Non-supported distribution; using default package set
|
||||
include_vars:
|
||||
file: __default_packages.yml
|
||||
|
||||
|
||||
- name: Deploy and configure SNMP
|
||||
block:
|
||||
- name: Set package name for Debian 12
|
||||
ansible.builtin.set_fact:
|
||||
snmpd_conf_snmp_pkg: snmpd
|
||||
when:
|
||||
- ansible_distribution | lower == 'debian'
|
||||
- ansible_distribution_major_version == '12'
|
||||
|
||||
- name: Install SNMP
|
||||
package:
|
||||
name: "{{ __snmp_pkg }}"
|
||||
ansible.builtin.package:
|
||||
name: "{{ snmpd_conf_snmp_pkg }}"
|
||||
state: present
|
||||
|
||||
- name: Ensure /etc/snmp directory is present
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /etc/snmp
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Deploy snmpd.conf
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: templates/snmpd_conf.j2
|
||||
dest: "{{ __snmpd_conf_file }}"
|
||||
mode: 0644
|
||||
dest: "{{ snmpd_conf_snmpd_conf_file }}"
|
||||
mode: "0644"
|
||||
notify: Restart_SNMPd
|
||||
|
||||
|
||||
rescue:
|
||||
- name: Unable to deploy SNMP
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "Unable to deploy SNMP to {{ inventory_hostname }}."
|
||||
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
###############################################
|
||||
# {{ __template_header }}
|
||||
# {{ snmpd_conf_template_header }}
|
||||
###############################################
|
||||
#
|
||||
# Configuration : {{ __snmpd_conf_file }}
|
||||
# Template Version : {{ __snmpd_conf_version}}-{{ __snmpd_conf_revision }}
|
||||
# Configuration : {{ snmpd_conf_snmpd_conf_file }}
|
||||
# Template Version : {{ snmpd_conf_snmpd_conf_version }}-{{ snmpd_conf_snmpd_conf_revision }}
|
||||
#
|
||||
# {{ __project_author }} ({{ __project_email }})
|
||||
# {{ snmpd_conf_project_author }} ({{ snmpd_conf_project_email }})
|
||||
###############################################
|
||||
|
||||
|
||||
@ -33,6 +33,6 @@ access MyRWGroup "" any noauth exact all all none
|
||||
###############################################################################
|
||||
# System contact information
|
||||
#
|
||||
syslocation {{ __snmpd_location }}
|
||||
syscontact {{ __snmpd_contact_name }} {{ __snmpd_contact_email }}
|
||||
syslocation {{ snmpd_conf_snmpd_location }}
|
||||
syscontact {{ snmpd_conf_snmpd_contact_name }} {{ snmpd_conf_snmpd_contact_email }}
|
||||
# -----------------------------------------------------------------------------
|
||||
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- snmpd_conf
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
__snmp_pkg: net-snmp
|
||||
|
||||
|
||||
...
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
__snmp_pkg: net-snmp
|
||||
|
||||
|
||||
...
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
__snmp_pkg: net-snmp
|
||||
|
||||
|
||||
...
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
__snmp_pkg: net-snmp
|
||||
|
||||
|
||||
...
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
__snmp_pkg: snmpd
|
||||
|
||||
|
||||
...
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
__snmp_pkg: snmpd
|
||||
|
||||
|
||||
...
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
__snmp_pkg: net-snmp
|
||||
|
||||
|
||||
...
|
4
roles/testing/README.md
Normal file
4
roles/testing/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
Role Name
|
||||
=========
|
||||
|
||||
A simple role to say hello to the world.
|
29
roles/testing/meta/main.yml
Normal file
29
roles/testing/meta/main.yml
Normal file
@ -0,0 +1,29 @@
|
||||
galaxy_info:
|
||||
author: Chris Hammer
|
||||
description: Simple default role to say hello world.
|
||||
|
||||
license: GPL-2.0-or-later
|
||||
|
||||
min_ansible_version: "2.14"
|
||||
|
||||
platforms:
|
||||
- name: Fedora
|
||||
versions:
|
||||
- all
|
||||
|
||||
- name: EL
|
||||
versions:
|
||||
- "8"
|
||||
- "9"
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
7
roles/testing/tasks/main.yml
Normal file
7
roles/testing/tasks/main.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: Hello World.
|
||||
ansible.builtin.debug:
|
||||
msg: Hello world.
|
||||
|
||||
|
||||
...
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
- name: Update package cache for Debian hosts
|
||||
apt:
|
||||
update_cache: yes
|
||||
update_cache: true
|
||||
when:
|
||||
- ansible_distribution|lower == 'debian'
|
||||
tags:
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
- name: Update package cache for RHEL/CentOS/Fedora hosts
|
||||
dnf:
|
||||
update_cache: yes
|
||||
update_cache: true
|
||||
when:
|
||||
- (ansible_distribution|lower == 'centos' or
|
||||
ansible_distribution|lower == 'fedora' or
|
||||
|
@ -1,2 +0,0 @@
|
||||
localhost
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- roles/update_all_packages
|
14
tests/unit-test.yml
Normal file
14
tests/unit-test.yml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: Test the role provided in extra_vars
|
||||
hosts: all
|
||||
become: false
|
||||
gather_facts: true
|
||||
|
||||
|
||||
tasks:
|
||||
- name: Include role to test
|
||||
ansible.builtin.include_role:
|
||||
name: "{{ __test_role | default('testing') }}"
|
||||
|
||||
|
||||
...
|
Loading…
x
Reference in New Issue
Block a user