You've already forked ansible-role-common
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 352ea54e11 | |||
| 6c80c1b07b | |||
| 463dfdf732 | |||
| 517ac07529 | |||
| 0bf187611a | |||
| a73eb8d69b | |||
| 3b9cff78df | |||
| 183d438c06 | |||
| 0902ffb768 | |||
| 29dc2c1142 | |||
| 86e63365ce | |||
| 98bd8c9a9e | |||
| 6e7800f161 | |||
| 65f576a65c | |||
| 8e8ea09da4 | |||
| ed89133f1b | |||
| ee0b737af7 |
83
.github/workflows/ci.yml
vendored
Normal file
83
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "**"
|
||||
tags:
|
||||
- "!**"
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
#cache: 'pip' # caching pip dependencies
|
||||
- name: Ensure requirements are installed
|
||||
run: pip install -r requirements.txt
|
||||
- name: Lint with ansible-lint
|
||||
run: ansible-lint -c ".ansible-lint"
|
||||
env:
|
||||
PY_COLORS: '1'
|
||||
ANSIBLE_FORCE_COLOR: '1'
|
||||
- name: Lint with yamllint
|
||||
run: yamllint .
|
||||
env:
|
||||
PY_COLORS: '1'
|
||||
ANSIBLE_FORCE_COLOR: '1'
|
||||
molecule:
|
||||
name: Molecule Test
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os: [almalinux8, almalinux9]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
#cache: 'pip' # caching pip dependencies
|
||||
|
||||
- name: Ensure requirements are installed
|
||||
run: pip install -r requirements.txt
|
||||
|
||||
- name: Run Molecule tests.
|
||||
run: molecule test
|
||||
env:
|
||||
PY_COLORS: '1'
|
||||
ANSIBLE_FORCE_COLOR: '1'
|
||||
MOLECULE_DISTRO: ${{ matrix.os }}
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- lint
|
||||
- molecule
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.22'
|
||||
- name: Install gitea provider for Go Semantic Release
|
||||
run: |
|
||||
mkdir -p .semrel/$(go env GOOS)_$(go env GOARCH)/provider-gitea/${GITEA_PROVIDER_VER}/ && \
|
||||
wget https://github.com/cybercinch/go-semantic-release-provider-gitea/releases/download/v${GITEA_PROVIDER_VER}/go-semantic-release-provider-gitea_v${GITEA_PROVIDER_VER}_linux_amd64 \
|
||||
-O .semrel/$(go env GOOS)_$(go env GOARCH)/provider-gitea/${GITEA_PROVIDER_VER}/gitea && \
|
||||
chmod a+x .semrel/$(go env GOOS)_$(go env GOARCH)/provider-gitea/${GITEA_PROVIDER_VER}/gitea
|
||||
env:
|
||||
GITEA_PROVIDER_VER: 1.0.11
|
||||
- run: |
|
||||
echo "github repo: ${GITHUB_REPOSITORY}"
|
||||
echo "env vars: $(env)"
|
||||
- uses: go-semantic-release/action@v1
|
||||
with:
|
||||
custom-arguments: --provider=gitea
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.G_TOKEN }}
|
||||
GITEA_HOST: ${{ secrets.G_SERVER_URL}}
|
||||
48
.woodpecker/release.yml
Normal file
48
.woodpecker/release.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
matrix:
|
||||
include:
|
||||
- MOLECULE_DISTRO: centos7
|
||||
- MOLECULE_DISTRO: almalinux8
|
||||
- MOLECULE_DISTRO: almalinux9
|
||||
|
||||
clone:
|
||||
git:
|
||||
image: woodpeckerci/plugin-git
|
||||
settings:
|
||||
recursive: true
|
||||
submodule_update_remote: true
|
||||
when:
|
||||
event: [ push ]
|
||||
|
||||
steps:
|
||||
create-release:
|
||||
name: Test on ${MOLECULE_DISTRO}
|
||||
image: guisea/ansible-molecule
|
||||
pull: true
|
||||
environment:
|
||||
PY_COLORS: '1'
|
||||
ANSIBLE_FORCE_COLOR: '1'
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
commands:
|
||||
- molecule test --scenario-name ${MOLECULE_SCENARIO:-default}
|
||||
#secrets: [ auth_duo_host, auth_duo_ikey, auth_duo_skey, auth_duo_mirror_url ]
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- manual
|
||||
ntfy:
|
||||
image: codeberg.org/l-x/woodpecker-ntfy
|
||||
settings:
|
||||
url: https://ntfy.cybercinch.nz/ci-status
|
||||
title: "Test failed for ${CI_REPO_NAME} - Distro: ${MOLECULE_DISTRO} Scenario: ${MOLECULE_SCENARIO:-default}"
|
||||
priority: urgent
|
||||
icon: https://woodpecker-ci.org/img/logo.svg
|
||||
tags: robot,warning,rotating_light,${CI_BUILD_EVENT},${CI_REPO_NAME}
|
||||
message: >
|
||||
📝 Commit by ${CI_COMMIT_AUTHOR} on ${CI_COMMIT_BRANCH}:
|
||||
${CI_COMMIT_MESSAGE}
|
||||
when:
|
||||
event: [ push, manual ]
|
||||
status: [ failure ]
|
||||
depends_on:
|
||||
- lint
|
||||
@@ -1,9 +1,9 @@
|
||||
# Common [](https://ci.cybercinch.nz/repos/6)
|
||||
# Common [](https://ci.cybercinch.nz/repos/8)
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
Requirements
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
debug:
|
||||
msg: "Virtualization is: {{ ansible_virtualization_type }}"
|
||||
|
||||
- name: Ensure DNS and SSH common config
|
||||
- name: Ensure Network Setup (RedHat only)
|
||||
template:
|
||||
src: "{{ network_config.src }}"
|
||||
dest: "{{ network_config.dest }}"
|
||||
@@ -16,8 +16,25 @@
|
||||
mode: u+rw,
|
||||
a+r,
|
||||
}
|
||||
when: >
|
||||
ansible_virtualization_type != "docker"
|
||||
and ansible_virtualization_type != "container"
|
||||
and ansible_os_family == "RedHat"
|
||||
loop_control:
|
||||
loop_var: network_config
|
||||
tags: dns
|
||||
|
||||
- name: Ensure Resolvers Configured
|
||||
template:
|
||||
src: "{{ network_config.src }}"
|
||||
dest: "{{ network_config.dest }}"
|
||||
mode: "{{ network_config.mode }}"
|
||||
backup: yes
|
||||
with_items:
|
||||
- { src: etc.resolv.conf.j2, dest: /etc/resolv.conf, mode: u+rw, a+r }
|
||||
when: ansible_virtualization_type != "docker" and ansible_virtualization_type != "container"
|
||||
when: >
|
||||
ansible_virtualization_type != "docker"
|
||||
and ansible_virtualization_type != "container"
|
||||
loop_control:
|
||||
loop_var: network_config
|
||||
tags: dns
|
||||
|
||||
@@ -15,41 +15,42 @@
|
||||
# /usr/local/bin/dynmotd
|
||||
#
|
||||
|
||||
USER=`/usr/bin/env whoami`
|
||||
HOSTNAME=`/usr/bin/env uname -n | /usr/bin/env cut -d. -f1`
|
||||
IP=`/usr/bin/env ip route get 1 | /usr/bin/env grep -Po '(?<=src.)[\w\d.]+'`
|
||||
IP6=`/usr/bin/env ip -6 addr | /usr/bin/env awk -F '[ \t]+|/' '$3 == "::1" { next;} $3 ~ /^fe80::/ { next ; } /inet6/ {print $3} '`
|
||||
NUM_CPU=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||
#ROOT=`/usr/bin/df / -x fuse.gvfs-fuse-daemon -Ph | /usr/bin/egrep -i 'root|logvol|vda' | awk '{print $4}' | tr -d '\n'`
|
||||
#HOME=`/usr/bin/df /home -x fuse.gvfs-fuse-daemon -Ph | grep home | awk '{print $4}' | tr -d '\n'`
|
||||
#BACKUP=`/usr/bin/df -x fuse.gvfs-fuse-daemon -Ph | grep backup | awk '{print $4}' | tr -d '\n'`
|
||||
FILESYSTEMS=`cat /etc/fstab | grep -v '#' | grep -v 'swap' | grep -v 'proc' | awk '{if(NF>0) {print $2}}'`
|
||||
MEMORY=`/usr/bin/env free -m | /usr/bin/env grep "Mem" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'`
|
||||
SWAP=`/usr/bin/env free -m | /usr/bin/env grep "Swap" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'`
|
||||
PSA=`/usr/bin/env ps -Afl | /usr/bin/env wc -l`
|
||||
if getent group "{{ admin_group }}" | grep -qw "$(whoami)"; then
|
||||
USER=`/usr/bin/env whoami`
|
||||
HOSTNAME=`/usr/bin/env uname -n | /usr/bin/env cut -d. -f1`
|
||||
IP=`/usr/bin/env ip route get 1 | /usr/bin/env grep -Po '(?<=src.)[\w\d.]+'`
|
||||
IP6=`/usr/bin/env ip -6 addr | /usr/bin/env awk -F '[ \t]+|/' '$3 == "::1" { next;} $3 ~ /^fe80::/ { next ; } /inet6/ {print $3} '`
|
||||
NUM_CPU=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||
#ROOT=`/usr/bin/df / -x fuse.gvfs-fuse-daemon -Ph | /usr/bin/egrep -i 'root|logvol|vda' | awk '{print $4}' | tr -d '\n'`
|
||||
#HOME=`/usr/bin/df /home -x fuse.gvfs-fuse-daemon -Ph | grep home | awk '{print $4}' | tr -d '\n'`
|
||||
#BACKUP=`/usr/bin/df -x fuse.gvfs-fuse-daemon -Ph | grep backup | awk '{print $4}' | tr -d '\n'`
|
||||
FILESYSTEMS=`cat /etc/fstab | grep -v '#' | grep -v 'swap' | grep -v 'proc' | awk '{if(NF>0) {print $2}}'`
|
||||
MEMORY=`/usr/bin/env free -m | /usr/bin/env grep "Mem" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'`
|
||||
SWAP=`/usr/bin/env free -m | /usr/bin/env grep "Swap" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'`
|
||||
PSA=`/usr/bin/env ps -Afl | /usr/bin/env wc -l`
|
||||
|
||||
# time of day
|
||||
HOUR=$(/usr/bin/env date +"%H")
|
||||
if [ $HOUR -lt 12 -a $HOUR -ge 0 ]
|
||||
then TIME="morning"
|
||||
elif [ $HOUR -lt 17 -a $HOUR -ge 12 ]
|
||||
then TIME="afternoon"
|
||||
else
|
||||
# time of day
|
||||
HOUR=$(/usr/bin/env date +"%H")
|
||||
if [ $HOUR -lt 12 -a $HOUR -ge 0 ]
|
||||
then TIME="morning"
|
||||
elif [ $HOUR -lt 17 -a $HOUR -ge 12 ]
|
||||
then TIME="afternoon"
|
||||
else
|
||||
TIME="evening"
|
||||
fi
|
||||
fi
|
||||
|
||||
#System uptime
|
||||
uptime=`/usr/bin/env cat /proc/uptime | cut -f1 -d.`
|
||||
upDays=$((uptime/60/60/24))
|
||||
upHours=$((uptime/60/60%24))
|
||||
upMins=$((uptime/60%60))
|
||||
upSecs=$((uptime%60))
|
||||
#System uptime
|
||||
uptime=`/usr/bin/env cat /proc/uptime | cut -f1 -d.`
|
||||
upDays=$((uptime/60/60/24))
|
||||
upHours=$((uptime/60/60%24))
|
||||
upMins=$((uptime/60%60))
|
||||
upSecs=$((uptime%60))
|
||||
|
||||
#System load
|
||||
LOADAVG=`/usr/bin/env cat /proc/loadavg`
|
||||
LOAD1=`echo $LOADAVG | /usr/bin/env awk {'print $1'}`
|
||||
LOAD5=`echo $LOADAVG | /usr/bin/env awk {'print $2'}`
|
||||
LOAD15=`echo $LOADAVG | /usr/bin/env awk {'print $3'}`
|
||||
#System load
|
||||
LOADAVG=`/usr/bin/env cat /proc/loadavg`
|
||||
LOAD1=`echo $LOADAVG | /usr/bin/env awk {'print $1'}`
|
||||
LOAD5=`echo $LOADAVG | /usr/bin/env awk {'print $2'}`
|
||||
LOAD15=`echo $LOADAVG | /usr/bin/env awk {'print $3'}`
|
||||
|
||||
echo ""
|
||||
echo -e "\e[7m--- GOOD $TIME $USER ----\e[0m"
|
||||
@@ -62,30 +63,30 @@ COLOR_VALUE="\e[31m"
|
||||
RESET_COLORS="\e[0m"
|
||||
echo -e "
|
||||
===========================================================================
|
||||
$COLOR_COLUMN- Hostname$RESET_COLORS............: $COLOR_VALUE $HOSTNAME $RESET_COLORS
|
||||
$COLOR_COLUMN- Hostname$RESET_COLORS............: $COLOR_VALUE $HOSTNAME $RESET_COLORS
|
||||
{% if common_show_ipv6 == true %}
|
||||
$COLOR_COLUMN- IP Address (Main v4)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS
|
||||
$COLOR_COLUMN- IP Address (Main v6)$RESET_COLORS: $COLOR_VALUE $IP6 $RESET_COLORS
|
||||
$COLOR_COLUMN- IP Address (Main v4)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS
|
||||
$COLOR_COLUMN- IP Address (Main v6)$RESET_COLORS: $COLOR_VALUE $IP6 $RESET_COLORS
|
||||
{% else %} $COLOR_COLUMN- IP Address (Default)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS
|
||||
{% endif %}
|
||||
{% if ansible_distribution == "Alpine" %}
|
||||
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE Alpine `/usr/bin/env cat /etc/os-release` $RESET_COLORS
|
||||
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE Alpine `/usr/bin/env cat /etc/os-release` $RESET_COLORS
|
||||
{% else %}
|
||||
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE `/usr/bin/env cat /etc/os-release | /usr/bin/env grep PRETTY_NAME | /usr/bin/env cut -d '"' -f 2` $RESET_COLORS
|
||||
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE `/usr/bin/env cat /etc/os-release | /usr/bin/env grep PRETTY_NAME | /usr/bin/env cut -d '"' -f 2` $RESET_COLORS
|
||||
{% endif %}
|
||||
{% if ansible_distribution != "Alpine" %}
|
||||
$COLOR_COLUMN- Users$RESET_COLORS...............: $COLOR_VALUE Currently `users | wc -w` user(s) logged on $RESET_COLORS
|
||||
$COLOR_COLUMN- Users$RESET_COLORS...............: $COLOR_VALUE Currently `users | wc -w` user(s) logged on $RESET_COLORS
|
||||
{% endif %}
|
||||
=========================================================================== $RESET_COLORS
|
||||
$COLOR_COLUMN- Current user$RESET_COLORS........: $COLOR_VALUE $USER $RESET_COLORS
|
||||
$COLOR_COLUMN- Number of CPU$RESET_COLORS.......: $COLOR_VALUE $NUM_CPU $RESET_COLORS
|
||||
$COLOR_COLUMN- CPU usage$RESET_COLORS...........: $COLOR_VALUE $LOAD1 - $LOAD5 - $LOAD15 (1-5-15 min) $RESET_COLORS
|
||||
$COLOR_COLUMN- Memory used$RESET_COLORS.........: $COLOR_VALUE $MEMORY (total-used-free) $RESET_COLORS
|
||||
$COLOR_COLUMN- Swap in use$RESET_COLORS.........: $COLOR_VALUE $SWAP (total-used-free) MB $RESET_COLORS
|
||||
$COLOR_COLUMN- Processes$RESET_COLORS...........: $COLOR_VALUE $PSA running $RESET_COLORS
|
||||
$COLOR_COLUMN- System uptime$RESET_COLORS.......: $COLOR_VALUE $upDays days $upHours hours $upMins minutes $upSecs seconds $RESET_COLORS
|
||||
$COLOR_COLUMN- Current user$RESET_COLORS........: $COLOR_VALUE $USER $RESET_COLORS
|
||||
$COLOR_COLUMN- Number of CPU$RESET_COLORS.......: $COLOR_VALUE $NUM_CPU $RESET_COLORS
|
||||
$COLOR_COLUMN- CPU usage$RESET_COLORS...........: $COLOR_VALUE $LOAD1 - $LOAD5 - $LOAD15 (1-5-15 min) $RESET_COLORS
|
||||
$COLOR_COLUMN- Memory used$RESET_COLORS.........: $COLOR_VALUE $MEMORY (total-used-free) $RESET_COLORS
|
||||
$COLOR_COLUMN- Swap in use$RESET_COLORS.........: $COLOR_VALUE $SWAP (total-used-free) MB $RESET_COLORS
|
||||
$COLOR_COLUMN- Processes$RESET_COLORS...........: $COLOR_VALUE $PSA running $RESET_COLORS
|
||||
$COLOR_COLUMN- System uptime$RESET_COLORS.......: $COLOR_VALUE $upDays days $upHours hours $upMins minutes $upSecs seconds $RESET_COLORS
|
||||
{% if ansible_virtualization_type != "lxc" %}
|
||||
$COLOR_COLUMN- Disk space$RESET_COLORS..........: "
|
||||
$COLOR_COLUMN- Disk space$RESET_COLORS..........: "
|
||||
for FS in ${FILESYSTEMS}; do
|
||||
echo -e " $COLOR_COLUMN- ..........$RESET_COLORS..........: $COLOR_VALUE `df -H ${FS} | grep -v 'Filesystem' | grep -v '^[[:space:]]*$' | awk '{print $6 \" \" $4}'` remaining $RESET_COLORS"
|
||||
done
|
||||
@@ -94,5 +95,9 @@ echo -e "
|
||||
===========================================================================
|
||||
"
|
||||
if [ -f /etc/motd ]; then
|
||||
/usr/bin/env cat /etc/motd
|
||||
fi
|
||||
/usr/bin/env cat /etc/motd
|
||||
fi
|
||||
else
|
||||
# Just exit :)
|
||||
exit 0
|
||||
fi;
|
||||
|
||||
Reference in New Issue
Block a user