Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
63ac9d6e4f | |||
584a33172c | |||
3cc31ecb40 | |||
665560250f | |||
d25730cb74 | |||
1ad31b8305 | |||
bdfa48f95d | |||
a29281515b | |||
152e7e3815 | |||
028bde883e | |||
bae88f96a7 | |||
d752b8064b | |||
7d3a8d8f77 |
@ -4,5 +4,3 @@ skip_list:
|
||||
- yaml[line-length]
|
||||
- no-changed-when
|
||||
- galaxy[no-changelog]
|
||||
- no-free-form
|
||||
- package-latest
|
||||
|
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
|
@ -7,7 +7,10 @@ on:
|
||||
|
||||
jobs:
|
||||
Ansible-Development-Pipeline:
|
||||
runs-on: ansible-dev-centos
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ansible-dev-centos9, ansible-dev-fedora39, ansible-dev-debian11, ansible-dev-debian12 ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Clone repository
|
||||
@ -15,18 +18,13 @@ jobs:
|
||||
|
||||
- name: Ansible Environment Verify
|
||||
run: |
|
||||
echo "BUILD HOST: $(cat /etc/hostname)" && echo
|
||||
echo "BUILD USER: $(whoami)" && echo
|
||||
echo "PWD: $(pwd)" && echo
|
||||
lscpu && echo
|
||||
. ./.ci.env && echo
|
||||
env && echo
|
||||
git log -1 && echo
|
||||
ansible --version && echo
|
||||
ansible-lint --version --offline && echo
|
||||
|
||||
. ./.drone.env
|
||||
env
|
||||
git log -1
|
||||
ansible --version
|
||||
ansible-lint --version
|
||||
|
||||
- name: Run Ansible-Lint
|
||||
run: |
|
||||
. ./.ci.env
|
||||
. ./.drone.env
|
||||
ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION
|
||||
|
@ -8,7 +8,7 @@ namespace: jchristianh
|
||||
name: baseos
|
||||
|
||||
# The version of the collection. Must be compatible with semantic versioning
|
||||
version: 1.0.36
|
||||
version: 1.0.30
|
||||
|
||||
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
|
||||
readme: README.md
|
||||
|
@ -1,2 +1,2 @@
|
||||
---
|
||||
requires_ansible: ">=2.15.0"
|
||||
requires_ansible: ">=2.14.0"
|
||||
|
@ -3,7 +3,7 @@
|
||||
ansible.builtin.set_fact:
|
||||
etc_hosts_etc_hosts_file: "{{ etc_hosts_etc_hosts_file }}.docker"
|
||||
when:
|
||||
- ansible_virtualization_type is search("docker|podman|container")
|
||||
- ansible_virtualization_type | regex_search("docker|podman|container")
|
||||
|
||||
|
||||
- name: Deploy {{ etc_hosts_etc_hosts_file }}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
- name: Use hostname module to set hostname, or failback to command module
|
||||
when:
|
||||
- not ansible_virtualization_type is search("docker|podman|container")
|
||||
- not ansible_virtualization_type | regex_search("docker|podman|container")
|
||||
block:
|
||||
- name: Set hostname for host using hostname module
|
||||
ansible.builtin.hostname:
|
||||
|
@ -1,12 +1,17 @@
|
||||
---
|
||||
- name: Format uptime using Jinja
|
||||
- name: Format uptime containing days
|
||||
ansible.builtin.set_fact:
|
||||
motd_uptime_formatted: |
|
||||
{% if 'day' in motd_host_uptime %}
|
||||
{{ motd_host_uptime | regex_replace(motd_day_filter, motd_day_filter_repl) }}
|
||||
{% else %}
|
||||
{{ motd_host_uptime | regex_replace(motd_nonday_filter, motd_nonday_filter_repl) }}
|
||||
{% endif %}
|
||||
uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_day_filter, motd_day_filter_repl) }}"
|
||||
when:
|
||||
- "'day' in motd_host_uptime"
|
||||
|
||||
|
||||
- name: Format uptime not containing days
|
||||
ansible.builtin.set_fact:
|
||||
uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_nonday_filter, motd_nonday_filter_repl) }}"
|
||||
when:
|
||||
- "'day' not in motd_host_uptime"
|
||||
|
||||
|
||||
- name: Update MOTD
|
||||
ansible.builtin.template:
|
||||
@ -14,3 +19,6 @@
|
||||
dest : "{{ motd_motd_file }}"
|
||||
mode : "0644"
|
||||
changed_when : false
|
||||
|
||||
|
||||
...
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
Host : {{ inventory_hostname }}
|
||||
IP : {{ motd_host_ip }}
|
||||
CPU : {{ ansible_processor_vcpus }} x {{ ansible_processor[2] | regex_replace('\\s+', ' ') }}
|
||||
CPU : {{ ansible_processor_vcpus }} x {{ ansible_processor[2] }}
|
||||
Memory : {{ "{0:0.2f}".format(ansible_memfree_mb/1024) }} GB free of {{ (ansible_memtotal_mb/1024)|round}} GB
|
||||
Platform : {{ ansible_distribution }} {{ ansible_distribution_version }} {{ ansible_kernel }}
|
||||
Up : {{ motd_uptime_formatted | trim }}
|
||||
Up : {{ uptime_formatted }}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
---
|
||||
node_status_host : node-status.thezengarden.net
|
||||
node_status_host : zg-lxut02.thezengarden.net
|
||||
node_status_user : chris
|
||||
node_status_group : chris
|
||||
node_status_dir : /home/chris/node_status
|
||||
node_status_file : status.csv
|
||||
node_status_lc : 3
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Update node status when not running in a container
|
||||
when: not ansible_virtualization_type is search("docker|podman|container")
|
||||
when: not ansible_virtualization_type | regex_search("docker|podman|container")
|
||||
block:
|
||||
- name: Create directory {{ node_status_dir }}
|
||||
ansible.builtin.file:
|
||||
@ -11,17 +11,19 @@
|
||||
run_once : true
|
||||
delegate_to : "{{ node_status_host }}"
|
||||
|
||||
|
||||
- name: Capture system uptime
|
||||
ansible.builtin.command : uptime
|
||||
register: node_status_sys_uptime
|
||||
register : r_node_status_uptime
|
||||
changed_when: false
|
||||
|
||||
|
||||
- name: Log node status
|
||||
ansible.builtin.lineinfile:
|
||||
path : "{{ node_status_dir }}/{{ node_status_file }}"
|
||||
state : present
|
||||
regexp : "{{ inventory_hostname }}"
|
||||
line: "{{ ansible_date_time.epoch }},,{{ inventory_hostname }},,{{ ansible_distribution }} {{ ansible_distribution_version }},,{{ node_status_sys_uptime.stdout }}"
|
||||
line : "{{ ansible_date_time.epoch }},,{{ inventory_hostname }},,{{ ansible_distribution }} {{ ansible_distribution_version }},,{{ r_node_status_uptime.stdout }}"
|
||||
create : true
|
||||
mode : '0644'
|
||||
owner : "{{ node_status_user }}"
|
||||
|
@ -3,7 +3,7 @@
|
||||
ansible.builtin.set_fact:
|
||||
resolv_conf_resolv_conf_file: "{{ resolv_conf_resolv_conf_file }}.container"
|
||||
when:
|
||||
- ansible_virtualization_type is search("docker|podman|container")
|
||||
- ansible_virtualization_type | regex_search("docker|podman|container")
|
||||
|
||||
|
||||
- name: Deploy {{ resolv_conf_resolv_conf_file }}
|
||||
|
@ -4,4 +4,4 @@
|
||||
name : snmpd
|
||||
state: restarted
|
||||
when:
|
||||
- not ansible_virtualization_type is search("docker|podman|container")
|
||||
- not ansible_virtualization_type | regex_search("docker|podman|container")
|
||||
|
@ -1,11 +1,12 @@
|
||||
---
|
||||
- name: Deploy and configure SNMP
|
||||
block:
|
||||
- name: Set package name for Debian
|
||||
- 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
|
||||
ansible.builtin.package:
|
||||
|
@ -1,21 +1,29 @@
|
||||
---
|
||||
- name: Update package cache for Debian hosts
|
||||
ansible.builtin.apt:
|
||||
apt:
|
||||
update_cache: true
|
||||
when:
|
||||
- "'apt' in ansible_pkg_mgr"
|
||||
- ansible_distribution|lower == 'debian'
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
|
||||
- name: Update package cache for RHEL/CentOS/Fedora hosts
|
||||
ansible.builtin.dnf:
|
||||
dnf:
|
||||
update_cache: true
|
||||
when:
|
||||
- "'dnf' in ansible_pkg_mgr"
|
||||
- (ansible_distribution|lower == 'centos' or
|
||||
ansible_distribution|lower == 'fedora' or
|
||||
ansible_distribution|lower == 'redhat')
|
||||
- ansible_distribution_major_version|int >= 8
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
|
||||
- name: Update all host packages
|
||||
ansible.builtin.package: name=* state=latest
|
||||
package: name=* state=latest
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
|
||||
...
|
||||
|
Reference in New Issue
Block a user