27 Commits

Author SHA1 Message Date
212e979ec6 fix: Removed additional linebreak 🐛
All checks were successful
CI / lint (push) Successful in 1m31s
CI / Molecule Test (almalinux9) (push) Successful in 2m58s
CI / Molecule Test (almalinux8) (push) Successful in 3m22s
CI / release (push) Successful in 20s
fixes #2
2024-04-26 15:09:00 +12:00
bea07d3c30 fix: Upgrade molecule ⬆️
All checks were successful
CI / lint (push) Successful in 48s
CI / Molecule Test (almalinux9) (push) Successful in 2m13s
CI / Molecule Test (almalinux8) (push) Successful in 2m40s
CI / release (push) Successful in 19s
2024-04-26 11:52:37 +12:00
2412d4dfbb chore: Updated Makefile to use act locally. 👷 🔨
Some checks failed
CI / lint (push) Successful in 46s
CI / Molecule Test (almalinux9) (push) Failing after 51s
CI / Molecule Test (almalinux8) (push) Failing after 53s
CI / release (push) Has been skipped
2024-04-26 11:40:40 +12:00
d39b45290a fix: Updated ansible-lint/yamlint ⬆️ 2024-04-26 11:39:27 +12:00
514defa749 chore: Updated default value 🔧 [skip ci] 2024-04-26 11:37:43 +12:00
7d6e1950d6 chore: Updated Readme.md 🔧 [skip ci] 2024-04-26 11:37:08 +12:00
af2a57fb62 chore: Updated badge on Readme 🔧
All checks were successful
CI / lint (push) Successful in 49s
CI / Molecule Test (almalinux9) (push) Successful in 2m24s
CI / Molecule Test (almalinux8) (push) Successful in 2m28s
CI / release (push) Successful in 20s
2024-04-26 10:49:35 +12:00
c776b9bdab chore: Enable cache 👷
All checks were successful
CI / lint (push) Successful in 36s
CI / Molecule Test (almalinux8) (push) Successful in 2m23s
CI / Molecule Test (almalinux9) (push) Successful in 2m24s
CI / release (push) Successful in 28s
2024-04-26 07:08:33 +12:00
779e10bf4c chore: Removal of unneeded files ⚰️
Some checks failed
CI / Molecule Test (almalinux8) (push) Blocked by required conditions
CI / Molecule Test (almalinux9) (push) Blocked by required conditions
CI / release (push) Blocked by required conditions
CI / lint (push) Has been cancelled
2024-04-24 22:56:53 +12:00
24b1721e8c fix: Further formatting tweaks 🎨
All checks were successful
CI / lint (push) Successful in 58s
CI / Molecule Test (almalinux8) (push) Successful in 2m28s
CI / Molecule Test (almalinux9) (push) Successful in 2m40s
CI / release (push) Successful in 18s
2024-04-24 15:47:25 +12:00
352ea54e11 fix: Correct funky formatting 🎨
All checks were successful
CI / lint (push) Successful in 55s
CI / Molecule Test (almalinux8) (push) Successful in 2m29s
CI / Molecule Test (almalinux9) (push) Successful in 2m40s
CI / release (push) Successful in 20s
2024-04-24 15:30:42 +12:00
6c80c1b07b chore: Lint fixes 🚨
All checks were successful
CI / lint (push) Successful in 35s
CI / Molecule Test (almalinux8) (push) Successful in 2m54s
CI / Molecule Test (almalinux9) (push) Successful in 2m49s
CI / release (push) Successful in 28s
2024-04-24 14:50:04 +12:00
463dfdf732 fix: Don't try add network config no RHEL 🐛
Some checks failed
CI / lint (push) Failing after 1m6s
CI / Molecule Test (almalinux8) (push) Has been skipped
CI / Molecule Test (almalinux9) (push) Has been skipped
CI / release (push) Has been skipped
2024-04-24 14:44:00 +12:00
517ac07529 chore: Updated label 👷 2024-04-24 14:40:43 +12:00
0bf187611a chore: Don't run on tags 👷
All checks were successful
CI / lint (push) Successful in 33s
CI / Molecule Tests ${{ matrix.os }} (almalinux8) (push) Successful in 2m42s
CI / Molecule Tests ${{ matrix.os }} (almalinux9) (push) Successful in 2m50s
CI / release (push) Successful in 18s
2024-04-24 13:38:54 +12:00
a73eb8d69b chore: Add requirements to steps 👷 2024-04-24 13:37:00 +12:00
3b9cff78df chore: Don't re-run on tag push (release) 👷 2024-04-24 13:36:23 +12:00
183d438c06 chore: Bump gitea provider ⬆️
All checks were successful
CI / lint (push) Successful in 36s
CI / Molecule Tests ${{ matrix.os }} (almalinux8) (push) Successful in 2m47s
CI / Molecule Tests ${{ matrix.os }} (almalinux9) (push) Successful in 2m39s
CI / release (push) Successful in 11s
2024-04-24 12:17:54 +12:00
0902ffb768 chore: Bump gitea provider ⬆️
Some checks failed
ci/woodpecker/push/lint Pipeline was successful
CI / lint (push) Successful in 1m14s
ci/woodpecker/push/release/2 Pipeline failed
ci/woodpecker/push/release/1 Pipeline was successful
CI / Molecule Tests ${{ matrix.os }} (almalinux8) (push) Successful in 3m26s
ci/woodpecker/push/release/3 Pipeline was successful
ci/woodpecker/push/test/1 Pipeline was successful
CI / Molecule Tests ${{ matrix.os }} (almalinux9) (push) Successful in 3m16s
ci/woodpecker/push/test/2 Pipeline was successful
ci/woodpecker/push/test/3 Pipeline was successful
ci/woodpecker/push/z.ntfy Pipeline failed
CI / release (push) Successful in 19s
2024-04-24 11:23:27 +12:00
29dc2c1142 fix: Linting errors on CI 🚨
Some checks failed
ci/woodpecker/push/lint Pipeline was successful
CI / lint (push) Successful in 49s
ci/woodpecker/push/release/2 Pipeline failed
CI / Molecule Tests ${{ matrix.os }} (almalinux8) (push) Successful in 3m29s
ci/woodpecker/push/release/1 Pipeline was successful
ci/woodpecker/push/release/3 Pipeline was successful
ci/woodpecker/push/test/1 Pipeline was successful
ci/woodpecker/push/test/3 Pipeline failed
ci/woodpecker/push/test/2 Pipeline failed
ci/woodpecker/push/z.ntfy unknown status
CI / Molecule Tests ${{ matrix.os }} (almalinux9) (push) Successful in 3m15s
CI / release (push) Failing after 16s
2024-04-23 23:07:13 +12:00
86e63365ce fix: Disable cache 👷
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/release/1 unknown status
ci/woodpecker/push/release/2 unknown status
ci/woodpecker/push/test/1 unknown status
ci/woodpecker/push/release/3 unknown status
ci/woodpecker/push/test/2 unknown status
ci/woodpecker/push/test/3 unknown status
ci/woodpecker/push/z.ntfy unknown status
CI / lint (push) Successful in 48s
CI / Molecule Tests ${{ matrix.os }} (almalinux8) (push) Successful in 3m15s
CI / Molecule Tests ${{ matrix.os }} (almalinux9) (push) Successful in 3m22s
CI / release (push) Failing after 5s
2024-04-23 22:51:46 +12:00
98bd8c9a9e fix: Correct Python version 💚
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/release/2 unknown status
ci/woodpecker/push/release/1 unknown status
ci/woodpecker/push/release/3 unknown status
ci/woodpecker/push/test/1 unknown status
ci/woodpecker/push/test/2 unknown status
ci/woodpecker/push/test/3 unknown status
ci/woodpecker/push/z.ntfy unknown status
CI / lint (push) Successful in 10m3s
CI / Molecule Tests ${{ matrix.os }} (almalinux8) (push) Failing after 7s
CI / Molecule Tests ${{ matrix.os }} (almalinux9) (push) Failing after 5s
CI / release (push) Failing after 14s
2024-04-23 22:08:59 +12:00
6e7800f161 chore: Update Readme 🔧
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/release/1 unknown status
ci/woodpecker/push/release/2 unknown status
ci/woodpecker/push/release/3 unknown status
ci/woodpecker/push/test/1 unknown status
ci/woodpecker/push/test/2 unknown status
ci/woodpecker/push/test/3 unknown status
ci/woodpecker/push/z.ntfy unknown status
CI / lint (push) Failing after 26s
CI / Molecule Tests ${{ matrix.os }} (almalinux8) (push) Failing after 5s
CI / Molecule Tests ${{ matrix.os }} (almalinux9) (push) Failing after 5s
CI / release (push) Failing after 14s
2024-04-23 16:57:47 +12:00
65f576a65c feat: Now only issue Dynamic MOTD if in admin_group
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/release/2 unknown status
ci/woodpecker/push/release/1 unknown status
ci/woodpecker/push/release/3 unknown status
ci/woodpecker/push/test/1 unknown status
ci/woodpecker/push/test/3 unknown status
ci/woodpecker/push/test/2 unknown status
ci/woodpecker/push/z.ntfy unknown status
2024-04-23 16:51:13 +12:00
8e8ea09da4 fix: Added workflow for Actions 👷 2024-04-23 16:50:20 +12:00
ed89133f1b chore: Update README.md [SKIP CI] 📝 2024-04-16 14:42:02 +12:00
ee0b737af7 chore: Update README.md [SKIP CI] 📝 2024-04-16 14:40:45 +12:00
10 changed files with 271 additions and 157 deletions

83
.github/workflows/ci.yml vendored Normal file
View 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
View 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

View File

@@ -18,15 +18,9 @@ test:
done
lint:
@echo "Linting with Ansible-lint"
@echo "Linting"
@act -j lint
@echo
ansible-lint -c ".ansible-lint" --exclude ".venv"
@echo
@echo "Linting with Yamllint"
@echo
yamllint .
@echo
docker: clean
docker buildx build --platform 'linux/amd64,linux/arm64' --push \

View File

@@ -1,40 +1,89 @@
# Common [![status-badge](https://ci.cybercinch.nz/api/badges/6/status.svg)](https://ci.cybercinch.nz/repos/6)
# Common [![status-badge](https://hub.cybercinch.nz/cybercinch/ansible-role-common/actions/workflows/ci.yml/badge.svg)](https://hub.cybercinch.nz/cybercinch/ansible-role-common/actions?workflow=ci.yml)
=========
A brief description of the role goes here.
This role is a collection of functionality to ease common setup of Linux based VM's. Some functionality for windows servers is available.
Requirements
Features:
* Dynamic motd - This displays information to administrators at login.
* Helper commands - These are commands to help with online resizing of Linux Partitions/Drives when running on VMWare.
* Set DNS resolvers for use on the host.
* Install common packages for the host (Win/Linux)
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.
Nil
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Role variables can be found in defaults/main.yml
```yaml
domain: exampledomain.com
ad_domain_joined: no
win_timezone: New Zealand Standard Time
vendors_hosts: []
dns_servers:
- 1.0.0.1
- 1.1.1.1
admin_group: admins
common_grub_timeout: 5
postfix_configure: false
common_packages: # Packages we will/would like to install
- nano
- git
- htop
- atop
- wget
- bind-utils
- yum-utils
- unzip
win_packages:
- notepadplusplus.install
- firefoxesr
- baretail
- 7zip.install
apply_win_updates: false
common_show_ipv6: false|bool
common_root_pwd: $y0urp@$$ ## You should always use a vault encrypted string here.
common_root_email: admin@somplace.co.nz # Configures forwarding address for root.
```
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Nil external dependencies. Requires only builtin functions
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
This is an example playbook. Executes the role overriding two variables.
You could alternately set these in host_vars or group_vars:
```yaml
- hosts: servers
- hosts: server
roles:
- { role: username.rolename, x: 42 }
- { role: cybercinch.common,
common_show_ipv6: true,
common_root_email: iamroot@example.com }
```
License
-------
BSD
MIT
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
This role was created in 2017 by [Aaron Guise](https://guise.net.nz/)

View File

@@ -1,5 +1,4 @@
---
# defaults file for guisea.common
domain: exampledomain.com
ad_domain_joined: no
win_timezone: New Zealand Standard Time
@@ -34,5 +33,5 @@ win_packages:
apply_win_updates: false
common_show_ipv6: false|bool
common_root_pwd: l3tm31nN0w
common_root_pwd: $y0urp@$$
common_root_email: admin@somplace.co.nz

View File

@@ -1,6 +1,6 @@
ansible-core<2.17
ansible-compat<4
molecule[docker]<5.0.0
ansible-lint==6.16.2
yamllint==1.32.0
ansible-compat >= 4
molecule[docker]== 24.2.1
ansible-lint==24.2.2
yamllint==1.35.1
passlib==1.7.4

View File

@@ -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

View File

@@ -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,37 +63,40 @@ COLOR_VALUE="\e[31m"
RESET_COLORS="\e[0m"
echo -e "
===========================================================================
$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
{% else %} $COLOR_COLUMN- IP Address (Default)$RESET_COLORS: $COLOR_VALUE $IP $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
{% 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"
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
{% endif %}
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;

View File

@@ -1,22 +0,0 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/linode/linode" {
version = "1.16.0"
constraints = "1.16.0"
hashes = [
"h1:JpBtHnebAi6yr/aDdlk8EybaEiEY+VPtFP3o0QoMTng=",
"zh:03c867440797b82012cd5d97f58fef5885dc0248683227299a39af836df222db",
"zh:0486be7f72d6ea73d10140e23be8c1d2772b2d8be28c7bb39c73be83601405cf",
"zh:181929d6880cac6500f4af1f3799385c47ccd69872cacf1042a3a48e445b2b02",
"zh:18b7f6cc1ddf86e28322638607e1f84c1e9d56824c26903e22d4d12352f20b6e",
"zh:4e65e7f9e17c334ff7047fc2dd8fc479c2509cba66834d89e2033a45e9275fe3",
"zh:6077eda3fdf77a5158d9dc1a0c38492e23f7d679b1ac96382ba92ebe92e19266",
"zh:642e7c96867c519176d84228a7f9104352212ae3c999b409eee1076b7ed90a96",
"zh:6451f5117125fad9884214fe2f2635a2bed95912e64cf1c66a57c38558dfe907",
"zh:83b957b30da19586393b9aea2cc93524a7d4c43dd07d11129a11d29c2b4bfb21",
"zh:852954fe6cfe5278bd7c3d1079a9832bbf8c58436486489ed85154c0a0600633",
"zh:a2385c51147a3c40707f7bfceb673c077e1054e8af6fb4c808cef56f995b8193",
"zh:d21cd5cb5a635d18547430fe6cdfe3c6898541f9f3adc110edbf8d6e0439390d",
]
}

View File

@@ -1,58 +0,0 @@
variable "drone_instances" {
description = "How many runner instances should there be?"
default = 3
}
variable "root_pass" {
description = "Root password to set on the node"
}
variable "linode_api_token" {
description = "Linode API Token"
}
variable "ssh_pubkey" {
description = "SSH key to be allowed access by default"
}
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "1.16.0"
}
}
backend "local" {
path = "/data/runner.tfstate"
}
}
provider "linode" {
token = var.linode_api_token
}
resource "linode_instance" "terraform-drone" {
connection {
type = "ssh"
user = "root"
password = var.root_pass
host = self.ip_address
}
count = var.drone_instances
image = "private/15818922"
label = "drone-runner-${count.index + 1}"
group = "docker"
tags = ["tag_Testing","docker"]
region = "ap-southeast"
type = "g6-standard-2"
authorized_keys = [ var.ssh_pubkey ]
root_pass = var.root_pass
provisioner "remote-exec" {
inline = [
"yum upgrade -y && systemctl restart docker",
"docker rm -f runner",
"docker run --detach --volume=/var/run/docker.sock:/var/run/docker.sock --env=DRONE_RPC_PROTO=https --env=DRONE_RPC_HOST=drone.guise.net.nz --env=DRONE_RPC_SECRET=super-duper-secret --env=DRONE_RUNNER_CAPACITY=2 --env=DRONE_RUNNER_NAME=drone-runner-${count.index + 1} --env=DRONE_RUNNER_LABELS='linodrone:true' --env=--publish=3000:3000 --restart=always --name=runner drone/drone-runner-docker:1"
]
}
}