You've already forked ansible-role-common
Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6eebd0b6f6 | |||
| 0b6e1f123a | |||
| 6e684e6efc | |||
| 0c1ae22375 | |||
| 131b683b49 | |||
| 682404a819 | |||
| a3ee65b213 | |||
| 0118504841 | |||
| 47e1eaca8b | |||
| 6365bf0c00 | |||
| 5c46cca25c | |||
| 70c581f82e | |||
| 83e5a49a28 | |||
| 93641c3cf8 | |||
| b663b49bab | |||
| 3ea8059b0f | |||
| e39de4a672 | |||
| ba98a986f1 | |||
| db1e526f0c | |||
| 303b8d7afb | |||
| 05208e5dae | |||
| ab31c5cdcf | |||
| 5ad8dde9aa | |||
| 0adb495154 | |||
| 600f469ca2 | |||
| 97d11bcb87 | |||
| 942fe21aef | |||
| bd61d62fd6 | |||
| e2b2acd56a | |||
| 19bfcc6eb2 | |||
| de589a11e0 | |||
| b5db07d6e5 | |||
| 5bac53eae1 | |||
| 347faec64c | |||
| 17329fe030 | |||
| 344cb5614d | |||
| 6003d42063 | |||
| 233b976243 | |||
| 5baf0d2d87 | |||
| 2d12d58960 | |||
| bc80a57b9c | |||
| 7f3147e3ee | |||
| e29f5d536d | |||
| 0af870d440 | |||
| 107705b584 | |||
| 6cbcbbad7a | |||
| 373273dabf | |||
| 23b9664ede | |||
| 00b1548103 | |||
| 19f54c9f52 | |||
| 1f6b4d51e0 | |||
| 2652ce3653 | |||
| 0f3221ac3e | |||
| 158095b011 | |||
| dec7676e87 | |||
| 943aecfe55 | |||
| 4924606317 | |||
| 41b5efa39b | |||
| aece1b662a | |||
| 3cd00a0d1d | |||
| f1999f47f7 | |||
| 0768d5fb3e |
@@ -1,3 +1,5 @@
|
|||||||
|
profile: basic
|
||||||
|
|
||||||
skip_list: # or 'skip_list' to silence them completely
|
skip_list: # or 'skip_list' to silence them completely
|
||||||
- experimental # all rules tagged as experimental
|
- experimental # all rules tagged as experimental
|
||||||
- unnamed-task # All tasks should be named
|
- unnamed-task # All tasks should be named
|
||||||
|
|||||||
139
.drone.jsonnet
139
.drone.jsonnet
@@ -1,139 +0,0 @@
|
|||||||
// Distros to Test on ;)
|
|
||||||
local distros = ['centos7',
|
|
||||||
'rockylinux8',
|
|
||||||
'debian10',
|
|
||||||
'debian11'];
|
|
||||||
|
|
||||||
/* Configuration of DIND */
|
|
||||||
local docker_service() =
|
|
||||||
{
|
|
||||||
name: 'docker',
|
|
||||||
image: 'docker:dind',
|
|
||||||
privileged: true,
|
|
||||||
volumes: [{ name: 'dockersock', path: '/var/run' },],
|
|
||||||
};
|
|
||||||
|
|
||||||
local email_notification() =
|
|
||||||
{
|
|
||||||
name: 'notify by email',
|
|
||||||
image: 'drillster/drone-email',
|
|
||||||
settings:
|
|
||||||
{ host:
|
|
||||||
{ from_secret: 'EMAIL_HOST' },
|
|
||||||
username:
|
|
||||||
{ from_secret: 'EMAIL_USER' },
|
|
||||||
password:
|
|
||||||
{ from_secret: 'EMAIL_PASS' },
|
|
||||||
from: 'drone@guise.net.nz'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
local test_distro(distribution) =
|
|
||||||
{
|
|
||||||
name: 'Molecule test on %(distribution)s' % { distribution: distribution },
|
|
||||||
volumes: [{ name: 'dockersock', path: '/var/run' },],
|
|
||||||
pull: true,
|
|
||||||
image: 'guisea/ansible-molecule:alpine-latest',
|
|
||||||
commands: [
|
|
||||||
'sleep 10', // give docker enough time to start
|
|
||||||
'mkdir ${DRONE_REPO_NAME}',
|
|
||||||
'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}',
|
|
||||||
'cd ${DRONE_REPO_NAME}',
|
|
||||||
'molecule test'
|
|
||||||
],
|
|
||||||
environment:
|
|
||||||
{ MOLECULE_DISTRO: '%(distribution)s' % { distribution: distribution }
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local gen_pipeline(distro) =
|
|
||||||
{kind: 'pipeline',
|
|
||||||
type: 'docker',
|
|
||||||
name: 'Test on %(distro)s' % { distro: distro },
|
|
||||||
steps:
|
|
||||||
[test_distro(distro)],
|
|
||||||
services:
|
|
||||||
[docker_service()],
|
|
||||||
volumes:
|
|
||||||
[{
|
|
||||||
name: 'dockersock',
|
|
||||||
temp: {},
|
|
||||||
},],
|
|
||||||
trigger:
|
|
||||||
{ event: {exclude: ['tag'],},},
|
|
||||||
when:
|
|
||||||
{ event: {exclude: ['tag']},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local gen_release() =
|
|
||||||
{kind: 'pipeline',
|
|
||||||
type: 'docker',
|
|
||||||
image: 'guisea/ansible-molecule:alpine-latest',
|
|
||||||
name: 'Generate Release',
|
|
||||||
commands: [
|
|
||||||
'sleep 10', // give docker enough time to start
|
|
||||||
'mkdir ${DRONE_REPO_NAME}',
|
|
||||||
'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}',
|
|
||||||
'cd ${DRONE_REPO_NAME}',
|
|
||||||
'apk update && apk add --no-cache curl',
|
|
||||||
'tar -czf ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz ./*', // Create an archive of the role
|
|
||||||
'curl --user ${GITEA_USER}:${GITEA_TOKEN} --upload-file ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz https://${GITEA_URL}/api/packages/${GITEA_REPOUSER}/generic/ansible-role-common/${DRONE_TAG}/${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz',
|
|
||||||
],
|
|
||||||
when:
|
|
||||||
{ event: {include: ['tag']},
|
|
||||||
},
|
|
||||||
trigger:
|
|
||||||
{ event: {include: ['tag'],},},
|
|
||||||
};
|
|
||||||
|
|
||||||
local gen_pipeline_release() =
|
|
||||||
{kind: 'pipeline',
|
|
||||||
type: 'docker',
|
|
||||||
name: 'Generate release from tag',
|
|
||||||
steps:
|
|
||||||
[gen_release()],
|
|
||||||
when:
|
|
||||||
{ event: {include: ['tag']},
|
|
||||||
},
|
|
||||||
trigger:
|
|
||||||
{ event: {include: ['tag'],},},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Generate the output
|
|
||||||
[
|
|
||||||
gen_pipeline('centos7'),
|
|
||||||
gen_pipeline('rockylinux8'),
|
|
||||||
gen_pipeline('debian10'),
|
|
||||||
gen_pipeline('debian11'),
|
|
||||||
{kind: 'pipeline',
|
|
||||||
type: 'docker',
|
|
||||||
name: 'Notify normal',
|
|
||||||
clone: {disable: true},
|
|
||||||
steps: [email_notification()],
|
|
||||||
trigger:
|
|
||||||
{ event: {exclude: ['tag'],},},
|
|
||||||
when:
|
|
||||||
{ status: [ 'success', 'failure' ] ,
|
|
||||||
event: {exclude: ['tag']},
|
|
||||||
},
|
|
||||||
depends_on:
|
|
||||||
['Test on %(distro)s' % { distro: distro }
|
|
||||||
for distro in distros]
|
|
||||||
},
|
|
||||||
gen_pipeline_release(),
|
|
||||||
{kind: 'pipeline',
|
|
||||||
type: 'docker',
|
|
||||||
clone: {disable: true},
|
|
||||||
name: 'Notify Tagged release',
|
|
||||||
steps: [email_notification()],
|
|
||||||
trigger:
|
|
||||||
{ event: {include: ['tag'],},},
|
|
||||||
when:
|
|
||||||
{ status: [ 'success', 'failure' ] ,
|
|
||||||
event: {include: ['tag']},
|
|
||||||
},
|
|
||||||
depends_on:
|
|
||||||
['Generate release from tag']
|
|
||||||
},
|
|
||||||
]
|
|
||||||
210
.drone.yml
210
.drone.yml
@@ -1,210 +0,0 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: runners
|
|
||||||
steps:
|
|
||||||
- commands:
|
|
||||||
- cd terraform
|
|
||||||
- terraform init
|
|
||||||
- terraform plan -out /data/runners.plan
|
|
||||||
- terraform apply /data/runners.plan
|
|
||||||
environment:
|
|
||||||
TF_VAR_linode_api_token:
|
|
||||||
from_secret: linode_api_token
|
|
||||||
TF_VAR_root_pass:
|
|
||||||
from_secret: root_pass
|
|
||||||
TF_VAR_ssh_pubkey:
|
|
||||||
from_secret: TF_VAR_ssh_pubkey
|
|
||||||
image: hashicorp/terraform:1.1.7
|
|
||||||
name: Provision with terraform
|
|
||||||
volumes:
|
|
||||||
- name: terraform-data
|
|
||||||
path: /data
|
|
||||||
type: docker
|
|
||||||
volumes:
|
|
||||||
- host:
|
|
||||||
path: /mnt/nfs/swarm/runners
|
|
||||||
name: terraform-data
|
|
||||||
---
|
|
||||||
depends_on:
|
|
||||||
- runners
|
|
||||||
kind: pipeline
|
|
||||||
name: Test on centos7
|
|
||||||
node:
|
|
||||||
linodrone: "true"
|
|
||||||
services:
|
|
||||||
- image: docker:dind
|
|
||||||
name: docker
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
steps:
|
|
||||||
- commands:
|
|
||||||
- sleep 10
|
|
||||||
- mkdir ${DRONE_REPO_NAME}
|
|
||||||
- rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}
|
|
||||||
- cd ${DRONE_REPO_NAME}
|
|
||||||
- molecule test
|
|
||||||
environment:
|
|
||||||
MOLECULE_DISTRO: centos7
|
|
||||||
image: guisea/ansible-molecule:latest
|
|
||||||
name: Molecule test on centos7
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
type: docker
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
temp: {}
|
|
||||||
---
|
|
||||||
depends_on:
|
|
||||||
- runners
|
|
||||||
kind: pipeline
|
|
||||||
name: Test on centos8
|
|
||||||
node:
|
|
||||||
linodrone: "true"
|
|
||||||
services:
|
|
||||||
- image: docker:dind
|
|
||||||
name: docker
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
steps:
|
|
||||||
- commands:
|
|
||||||
- sleep 10
|
|
||||||
- mkdir ${DRONE_REPO_NAME}
|
|
||||||
- rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}
|
|
||||||
- cd ${DRONE_REPO_NAME}
|
|
||||||
- molecule test
|
|
||||||
environment:
|
|
||||||
MOLECULE_DISTRO: centos8
|
|
||||||
image: guisea/ansible-molecule:latest
|
|
||||||
name: Molecule test on centos8
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
type: docker
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
temp: {}
|
|
||||||
---
|
|
||||||
depends_on:
|
|
||||||
- runners
|
|
||||||
kind: pipeline
|
|
||||||
name: Test on rockylinux8
|
|
||||||
node:
|
|
||||||
linodrone: "true"
|
|
||||||
services:
|
|
||||||
- image: docker:dind
|
|
||||||
name: docker
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
steps:
|
|
||||||
- commands:
|
|
||||||
- sleep 10
|
|
||||||
- mkdir ${DRONE_REPO_NAME}
|
|
||||||
- rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}
|
|
||||||
- cd ${DRONE_REPO_NAME}
|
|
||||||
- molecule test
|
|
||||||
environment:
|
|
||||||
MOLECULE_DISTRO: rockylinux8
|
|
||||||
image: guisea/ansible-molecule:latest
|
|
||||||
name: Molecule test on rockylinux8
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
type: docker
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
temp: {}
|
|
||||||
---
|
|
||||||
depends_on:
|
|
||||||
- runners
|
|
||||||
kind: pipeline
|
|
||||||
name: Test on debian10
|
|
||||||
node:
|
|
||||||
linodrone: "true"
|
|
||||||
services:
|
|
||||||
- image: docker:dind
|
|
||||||
name: docker
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
steps:
|
|
||||||
- commands:
|
|
||||||
- sleep 10
|
|
||||||
- mkdir ${DRONE_REPO_NAME}
|
|
||||||
- rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}
|
|
||||||
- cd ${DRONE_REPO_NAME}
|
|
||||||
- molecule test
|
|
||||||
environment:
|
|
||||||
MOLECULE_DISTRO: debian10
|
|
||||||
image: guisea/ansible-molecule:latest
|
|
||||||
name: Molecule test on debian10
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
type: docker
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
temp: {}
|
|
||||||
---
|
|
||||||
depends_on:
|
|
||||||
- runners
|
|
||||||
kind: pipeline
|
|
||||||
name: Test on debian11
|
|
||||||
node:
|
|
||||||
linodrone: "true"
|
|
||||||
services:
|
|
||||||
- image: docker:dind
|
|
||||||
name: docker
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
steps:
|
|
||||||
- commands:
|
|
||||||
- sleep 10
|
|
||||||
- mkdir ${DRONE_REPO_NAME}
|
|
||||||
- rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}
|
|
||||||
- cd ${DRONE_REPO_NAME}
|
|
||||||
- molecule test
|
|
||||||
environment:
|
|
||||||
MOLECULE_DISTRO: debian11
|
|
||||||
image: guisea/ansible-molecule:latest
|
|
||||||
name: Molecule test on debian11
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
type: docker
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
temp: {}
|
|
||||||
---
|
|
||||||
depends_on:
|
|
||||||
- Test on centos7
|
|
||||||
- Test on centos8
|
|
||||||
- Test on rockylinux8
|
|
||||||
- Test on debian10
|
|
||||||
- Test on debian11
|
|
||||||
kind: pipeline
|
|
||||||
name: Notify
|
|
||||||
steps:
|
|
||||||
- image: drillster/drone-email
|
|
||||||
name: notify by email
|
|
||||||
settings:
|
|
||||||
from: drone@guise.net.nz
|
|
||||||
host: mail.guise.net.nz
|
|
||||||
password:
|
|
||||||
from_secret: EMAIL_PASS
|
|
||||||
username:
|
|
||||||
from_secret: EMAIL_USER
|
|
||||||
type: docker
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- success
|
|
||||||
- failure
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@ roles/*
|
|||||||
!files/authorized_keys/
|
!files/authorized_keys/
|
||||||
files/authorized_keys/*
|
files/authorized_keys/*
|
||||||
!files/authorized_keys/.gitkeep
|
!files/authorized_keys/.gitkeep
|
||||||
|
env/
|
||||||
|
|
||||||
# Do not commit Vault password
|
# Do not commit Vault password
|
||||||
.vault_password.txt
|
.vault_password.txt
|
||||||
|
|||||||
28
.woodpecker/cron.yml
Normal file
28
.woodpecker/cron.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- MOLECULE_DISTRO: centos7
|
||||||
|
- MOLECULE_DISTRO: almalinux8
|
||||||
|
|
||||||
|
clone:
|
||||||
|
git:
|
||||||
|
image: woodpeckerci/plugin-git
|
||||||
|
settings:
|
||||||
|
recursive: true
|
||||||
|
submodule_update_remote: true
|
||||||
|
when:
|
||||||
|
event: [ cron ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
test:
|
||||||
|
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}
|
||||||
|
when:
|
||||||
|
event: [ cron ]
|
||||||
43
.woodpecker/lint.yml
Normal file
43
.woodpecker/lint.yml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
clone:
|
||||||
|
git:
|
||||||
|
image: woodpeckerci/plugin-git
|
||||||
|
settings:
|
||||||
|
recursive: true
|
||||||
|
submodule_update_remote: true
|
||||||
|
when:
|
||||||
|
event: [ push, manual ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
ansible-lint:
|
||||||
|
group: test
|
||||||
|
name: "Lint: Ansible-lint"
|
||||||
|
image: guisea/ansible-molecule
|
||||||
|
environment:
|
||||||
|
PY_COLORS: '1'
|
||||||
|
ANSIBLE_FORCE_COLOR: '1'
|
||||||
|
commands:
|
||||||
|
- ansible-lint -c ".ansible-lint"
|
||||||
|
when:
|
||||||
|
event: [ push, manual ]
|
||||||
|
yamllint:
|
||||||
|
group: test
|
||||||
|
name: "Lint: Yamllint"
|
||||||
|
image: guisea/ansible-molecule
|
||||||
|
commands:
|
||||||
|
- yamllint -f colored .
|
||||||
|
when:
|
||||||
|
event: [ push, manual ]
|
||||||
|
ntfy:
|
||||||
|
image: codeberg.org/l-x/woodpecker-ntfy
|
||||||
|
settings:
|
||||||
|
url: https://ntfy.cybercinch.nz/ci-status
|
||||||
|
title: "Lint failed for ${CI_REPO_NAME}"
|
||||||
|
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 ]
|
||||||
47
.woodpecker/test.yml
Normal file
47
.woodpecker/test.yml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- MOLECULE_DISTRO: centos7
|
||||||
|
- MOLECULE_DISTRO: almalinux8
|
||||||
|
|
||||||
|
clone:
|
||||||
|
git:
|
||||||
|
image: woodpeckerci/plugin-git
|
||||||
|
settings:
|
||||||
|
recursive: true
|
||||||
|
submodule_update_remote: true
|
||||||
|
when:
|
||||||
|
event: [ push, manual ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
test:
|
||||||
|
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
|
||||||
16
.woodpecker/z.ntfy-cron.yml
Normal file
16
.woodpecker/z.ntfy-cron.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
skip_clone: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
ntfy-success:
|
||||||
|
image: codeberg.org/l-x/woodpecker-ntfy
|
||||||
|
settings:
|
||||||
|
url: https://ntfy.cybercinch.nz/ci-status
|
||||||
|
title: Build succeeded on ${CI_REPO_NAME}
|
||||||
|
priority: urgent
|
||||||
|
icon: https://woodpecker-ci.org/img/logo.svg
|
||||||
|
tags: robot,white_check_mark,${CI_BUILD_EVENT},${CI_REPO_NAME}
|
||||||
|
message: >
|
||||||
|
Test success when run by cron for ${CI_REPO_NAME}.
|
||||||
|
depends_on:
|
||||||
|
- "cron"
|
||||||
|
runs_on: [ success ]
|
||||||
20
.woodpecker/z.ntfy.yml
Normal file
20
.woodpecker/z.ntfy.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
skip_clone: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
ntfy:
|
||||||
|
image: codeberg.org/l-x/woodpecker-ntfy
|
||||||
|
settings:
|
||||||
|
url: https://ntfy.cybercinch.nz/ci-status
|
||||||
|
title: "Build completed for ${CI_REPO_NAME}"
|
||||||
|
priority: urgent
|
||||||
|
icon: https://woodpecker-ci.org/img/logo.svg
|
||||||
|
tags: robot,tada,white_check_mark,${CI_BUILD_EVENT},${CI_REPO_NAME}
|
||||||
|
message: >
|
||||||
|
📝 Commit by ${CI_COMMIT_AUTHOR} on ${CI_COMMIT_BRANCH}:
|
||||||
|
${CI_COMMIT_MESSAGE}
|
||||||
|
when:
|
||||||
|
event: [ push, manual ]
|
||||||
|
status: [ success ]
|
||||||
|
depends_on:
|
||||||
|
- lint
|
||||||
|
- test
|
||||||
16
.woodpecker/zz.ntfy-cron-failed.yml
Normal file
16
.woodpecker/zz.ntfy-cron-failed.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
skip_clone: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
ntfy-failed:
|
||||||
|
image: codeberg.org/l-x/woodpecker-ntfy
|
||||||
|
settings:
|
||||||
|
url: https://ntfy.cybercinch.nz/ci-status
|
||||||
|
title: Build failed on ${CI_REPO_NAME}
|
||||||
|
priority: urgent
|
||||||
|
icon: https://woodpecker-ci.org/img/logo.svg
|
||||||
|
tags: robot,rotating_light,no_entry,${CI_BUILD_EVENT},${CI_REPO_NAME}
|
||||||
|
message: >
|
||||||
|
Test failed when run by cron for ${CI_REPO_NAME}.
|
||||||
|
depends_on:
|
||||||
|
- "cron"
|
||||||
|
runs_on: [ failure ]
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
# Based on ansible-lint config
|
# Based on ansible-lint config
|
||||||
extends: default
|
extends: default
|
||||||
|
|
||||||
|
ignore: |
|
||||||
|
.venv/
|
||||||
rules:
|
rules:
|
||||||
braces:
|
braces:
|
||||||
max-spaces-inside: 1
|
max-spaces-inside: 1
|
||||||
@@ -26,8 +28,8 @@ rules:
|
|||||||
indentation: disable
|
indentation: disable
|
||||||
key-duplicates: enable
|
key-duplicates: enable
|
||||||
line-length: disable
|
line-length: disable
|
||||||
new-line-at-end-of-file: disable
|
new-line-at-end-of-file: enable
|
||||||
new-lines:
|
new-lines:
|
||||||
type: unix
|
type: unix
|
||||||
trailing-spaces: disable
|
trailing-spaces: enable
|
||||||
truthy: disable
|
truthy: disable
|
||||||
|
|||||||
42
Makefile
Normal file
42
Makefile
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
.PHONY: clean virtualenv lint test docker dist dist-upload
|
||||||
|
|
||||||
|
clean:
|
||||||
|
find . -name '*.py[co]' -delete
|
||||||
|
|
||||||
|
virtualenv:
|
||||||
|
virtualenv --prompt '|> ansible-role-common <| ' .venv
|
||||||
|
.venv/bin/pip install --upgrade pip
|
||||||
|
.venv/bin/pip install -r requirements.txt
|
||||||
|
.venv/bin/ansible-galaxy collection install -r requirements.yml
|
||||||
|
@echo
|
||||||
|
@echo "VirtualENV Setup Complete. Now run: source .venv/bin/activate"
|
||||||
|
@echo
|
||||||
|
|
||||||
|
test:
|
||||||
|
for distro in centos7 almalinux8 ; do \
|
||||||
|
MOLECULE_DISTRO=$$distro molecule test --all ; \
|
||||||
|
done
|
||||||
|
|
||||||
|
lint:
|
||||||
|
@echo "Linting with Ansible-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 \
|
||||||
|
-t hub.cybercinch.nz/cybercinch/imap_retention_manager:latest \
|
||||||
|
-t docker.io/cybercinch/imap_retention_manager:latest .
|
||||||
|
|
||||||
|
dist: clean
|
||||||
|
rm -rf dist/*
|
||||||
|
python setup.py sdist
|
||||||
|
python setup.py bdist_wheel
|
||||||
|
|
||||||
|
dist-upload:
|
||||||
|
twine upload dist/*
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Common [](https://drone.guise.net.nz/ansible-roles/common)
|
# Common [](https://ci.cybercinch.nz/repos/4)
|
||||||
=========
|
=========
|
||||||
|
|
||||||
A brief description of the role goes here.
|
A brief description of the role goes here.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ dns_servers:
|
|||||||
- 1.0.0.1
|
- 1.0.0.1
|
||||||
- 1.1.1.1
|
- 1.1.1.1
|
||||||
|
|
||||||
ADMIN_GROUP: admins
|
admin_group: admins
|
||||||
|
|
||||||
|
|
||||||
common_grub_timeout: 5
|
common_grub_timeout: 5
|
||||||
@@ -24,15 +24,15 @@ common_packages:
|
|||||||
- bind-utils
|
- bind-utils
|
||||||
- yum-utils
|
- yum-utils
|
||||||
- unzip
|
- unzip
|
||||||
|
|
||||||
win_packages:
|
win_packages:
|
||||||
- notepadplusplus.install
|
- notepadplusplus.install
|
||||||
- firefoxesr
|
- firefoxesr
|
||||||
- baretail
|
- baretail
|
||||||
- 7zip.install
|
- 7zip.install
|
||||||
|
|
||||||
apply_win_updates: false
|
apply_win_updates: false
|
||||||
|
|
||||||
common_show_ipv6: false|bool
|
common_show_ipv6: false|bool
|
||||||
common_root_pwd: l3tm31nN0w
|
common_root_pwd: l3tm31nN0w
|
||||||
common_root_email: admin@somplace.co.nz
|
common_root_email: admin@somplace.co.nz
|
||||||
|
|||||||
8
files/helpers/set_dhcp_ip.sh
Normal file
8
files/helpers/set_dhcp_ip.sh
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script will reset the IP Address back to default of DHCP
|
||||||
|
# helpful for a pending restore
|
||||||
|
|
||||||
|
/bin/nmcli c m "System eth0" ipv4.method auto
|
||||||
|
/bin/nmcli c m "System eth0" ipv4.address "" ipv4.gateway ""
|
||||||
|
/bin/nmcli connection up "System eth0"
|
||||||
48
files/helpers/set_static_ip.sh
Normal file
48
files/helpers/set_static_ip.sh
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# get subnet
|
||||||
|
subnet=$(ip a | grep "inet " | tail -1 | awk '{print $2}')
|
||||||
|
|
||||||
|
# get router/gateway
|
||||||
|
router=$(ip route show | head -1 | awk '{print $3}')
|
||||||
|
|
||||||
|
# get size of network portion of address in bytes
|
||||||
|
sz=$(echo $subnet | awk -F / '{print $2}')
|
||||||
|
bytes=$(("$sz" / 8))
|
||||||
|
prefix=$(echo "$subnet" | cut -d. -f1-$bytes) # e.g., 192.168.0
|
||||||
|
|
||||||
|
# get IP address to be set
|
||||||
|
IP=$(hostname -I | awk '{print $1}') # current IP
|
||||||
|
echo -n "Keep IP address?—$IP [yn]> "
|
||||||
|
read -r ans
|
||||||
|
if [ "$ans" == "n" ]; then
|
||||||
|
echo -n "Enter new IP address: "
|
||||||
|
read -r IP
|
||||||
|
# check if specified IP is properly formatted
|
||||||
|
if [[ ! $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||||
|
echo Invalid IP
|
||||||
|
fi
|
||||||
|
# check if specified IP works for local network
|
||||||
|
if [[ ! $IP =~ ^$prefix ]]; then
|
||||||
|
echo "ERROR: Specified IP not usable for local network"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if specified IP is properly formatted
|
||||||
|
if [[ ! $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||||
|
echo Invalid IP
|
||||||
|
fi
|
||||||
|
|
||||||
|
# fetch the UUID
|
||||||
|
UUID=$(nmcli connection show | tail -1 | awk '{print $4}')
|
||||||
|
if [[ "$UUID" == "ethernet" ]]; then
|
||||||
|
# This is the other format of nmcli connection show
|
||||||
|
UUID=$(nmcli connection show | head -2 | tail -1 | awk '{print $3}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# run commands to set up the permanent IP address
|
||||||
|
nmcli connection modify "$UUID" IPv4.address "$IP"/"$sz"
|
||||||
|
nmcli connection modify "$UUID" IPv4.gateway "$router"
|
||||||
|
nmcli connection modify "$UUID" IPv4.method manual
|
||||||
|
nmcli connection up "$UUID"
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
name: ntpd
|
name: ntpd
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
- name: reboot windows
|
- name: Reboot Windows
|
||||||
win_reboot:
|
win_reboot:
|
||||||
|
|
||||||
- name: restart NetworkManager
|
- name: Restart NetworkManager
|
||||||
service:
|
service:
|
||||||
name: NetworkManager
|
name: NetworkManager
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
tasks:
|
tasks:
|
||||||
- name: "Include common"
|
- name: "Include common"
|
||||||
include_role:
|
include_role:
|
||||||
name: "common"
|
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ dependency:
|
|||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
- name: instance
|
- name: molecule-${MOLECULE_DISTRO:-almalinux8}
|
||||||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
|
image: "cybercinch/docker-${MOLECULE_DISTRO:-almalinux8}-ansible:latest"
|
||||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
volumes:
|
volumes:
|
||||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
@@ -13,9 +13,11 @@ platforms:
|
|||||||
pre_build_image: true
|
pre_build_image: true
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
|
env:
|
||||||
|
MOLECULE_NO_LOG: true
|
||||||
# verifier:
|
# verifier:
|
||||||
# name: ansible
|
# name: ansible
|
||||||
lint: |
|
# lint: |
|
||||||
set -e
|
# set -e
|
||||||
yamllint .
|
# yamllint .
|
||||||
ansible-lint
|
# ansible-lint
|
||||||
|
|||||||
6
requirements.txt
Normal file
6
requirements.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
ansible-core<2.17
|
||||||
|
ansible-compat<4
|
||||||
|
molecule[docker]<5.0.0
|
||||||
|
ansible-lint==6.16.2
|
||||||
|
yamllint==1.32.0
|
||||||
|
passlib==1.7.4
|
||||||
3
requirements.yml
Normal file
3
requirements.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
collections:
|
||||||
|
- ansible.windows
|
||||||
|
- community.general
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
- include_tasks: networking.yml
|
- include_tasks: networking.yml
|
||||||
|
|
||||||
- name: Ensure common packages (RHEL)
|
- name: Ensure common packages (RHEL)
|
||||||
yum:
|
yum:
|
||||||
name: "{{ common_packages }}"
|
name: "{{ common_packages }}"
|
||||||
state: present
|
state: present
|
||||||
enablerepo: epel
|
enablerepo: epel
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
enablerepo: ol7_developer_EPEL
|
enablerepo: ol7_developer_EPEL
|
||||||
when: ansible_distribution == 'OracleLinux'
|
when: ansible_distribution == 'OracleLinux'
|
||||||
tags: packages
|
tags: packages
|
||||||
|
|
||||||
- name: Check if SELinux is installed
|
- name: Check if SELinux is installed
|
||||||
stat:
|
stat:
|
||||||
path: /etc/selinux/config
|
path: /etc/selinux/config
|
||||||
@@ -38,7 +38,9 @@
|
|||||||
# tags: security
|
# tags: security
|
||||||
|
|
||||||
- name: Create admin group
|
- name: Create admin group
|
||||||
group: name={{ ADMIN_GROUP }} state=present
|
group:
|
||||||
|
name: "{{ admin_group }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Configure yum limit
|
- name: Configure yum limit
|
||||||
lineinfile:
|
lineinfile:
|
||||||
@@ -49,25 +51,18 @@
|
|||||||
|
|
||||||
- name: Ensure Helpers are present
|
- name: Ensure Helpers are present
|
||||||
copy:
|
copy:
|
||||||
src: "{{ helpers.src }}"
|
src: helpers/
|
||||||
dest: "{{ helpers.dest }}"
|
dest: /usr/local/bin/
|
||||||
mode: u+rwx,g+rx,o+rx
|
mode: u+rwx,g+rx,o+rx
|
||||||
with_items:
|
|
||||||
- src: helpers/reload_scsi_devices
|
|
||||||
dest: /usr/local/bin/reload_scsi_devices
|
|
||||||
- src: helpers/reload_scsi_hosts
|
|
||||||
dest: /usr/local/bin/reload_scsi_hosts
|
|
||||||
loop_control:
|
|
||||||
loop_var: helpers
|
|
||||||
|
|
||||||
- name: Ensure Hostname is set
|
- name: Ensure Hostname is set
|
||||||
hostname:
|
hostname:
|
||||||
name: "{{ inventory_hostname }}.{{ domain }}"
|
name: "{{ inventory_hostname }}.{{ domain }}"
|
||||||
when: ansible_virtualization_type != "docker"
|
when: ansible_virtualization_type != "docker" and ansible_virtualization_type != "container"
|
||||||
|
|
||||||
- name: Change root password
|
- name: Change root password
|
||||||
user:
|
user:
|
||||||
name: root
|
name: root
|
||||||
password: "{{ common_root_pwd | password_hash('sha512') }}"
|
password: "{{ common_root_pwd | password_hash('sha512') }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
tags: rootpw
|
tags: rootpw
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
admin_password: "{{ vault_ad_password }}"
|
admin_password: "{{ vault_ad_password }}"
|
||||||
domain_name: "{{ authconfig_domain }}"
|
domain_name: "{{ authconfig_domain }}"
|
||||||
when: ad_domain_joined
|
when: ad_domain_joined
|
||||||
notify: reboot windows
|
notify: Reboot Windows
|
||||||
- meta: flush_handlers
|
- meta: flush_handlers
|
||||||
|
|
||||||
- name: Ensure Important dirs exist
|
- name: Ensure Important dirs exist
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
- name: Apply Windows Updates
|
- name: Apply Windows Updates
|
||||||
win_updates:
|
win_updates:
|
||||||
when: apply_windows_updates
|
when: apply_windows_updates
|
||||||
notify: reboot windows
|
notify: Reboot Windows
|
||||||
- meta: flush_handlers
|
- meta: flush_handlers
|
||||||
|
|
||||||
- name: Ensure default applications installed
|
- name: Ensure default applications installed
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Postfix Configuration
|
- name: Postfix Configuration
|
||||||
|
when: postfix_configure
|
||||||
block:
|
block:
|
||||||
- name: postfix | Apply postfix configuration
|
- name: Postfix | Apply postfix configuration
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "{{ configurations.dest }}"
|
dest: "{{ configurations.dest }}"
|
||||||
regexp: "{{ configurations.regexp }}"
|
regexp: "{{ configurations.regexp }}"
|
||||||
@@ -33,12 +34,11 @@
|
|||||||
loop_control:
|
loop_control:
|
||||||
loop_var: configurations
|
loop_var: configurations
|
||||||
|
|
||||||
- name: postfix | Ensure Postfix is Started/Enabled
|
- name: Postfix | Ensure Postfix is Started/Enabled
|
||||||
service:
|
service:
|
||||||
name: postfix
|
name: postfix
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: postfix_configure
|
|
||||||
|
|
||||||
- name: Ensure root forwarding address is set
|
- name: Ensure root forwarding address is set
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
no_extra_spaces: yes
|
no_extra_spaces: yes
|
||||||
when: "ansible_os_family == 'RedHat' and ansible_distribution_major_version > '6'"
|
when: "ansible_os_family == 'RedHat' and ansible_distribution_major_version > '6'"
|
||||||
notify:
|
notify:
|
||||||
- Check if grub.cfg exists
|
- Check if grub.cfg exists
|
||||||
- Update GRUB
|
- Update GRUB
|
||||||
tags:
|
tags:
|
||||||
- grub
|
- grub
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
---
|
---
|
||||||
|
- name: What is virtualization type?
|
||||||
|
debug:
|
||||||
|
msg: "Virtualization is: {{ ansible_virtualization_type }}"
|
||||||
|
|
||||||
- name: Ensure DNS and SSH common config
|
- name: Ensure DNS and SSH common config
|
||||||
template:
|
template:
|
||||||
src: "{{ network_config.src }}"
|
src: "{{ network_config.src }}"
|
||||||
@@ -13,7 +17,7 @@
|
|||||||
a+r,
|
a+r,
|
||||||
}
|
}
|
||||||
- { src: etc.resolv.conf.j2, dest: /etc/resolv.conf, mode: u+rw, a+r }
|
- { src: etc.resolv.conf.j2, dest: /etc/resolv.conf, mode: u+rw, a+r }
|
||||||
when: ansible_virtualization_type != "docker"
|
when: ansible_virtualization_type != "docker" and ansible_virtualization_type != "container"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: network_config
|
loop_var: network_config
|
||||||
tags: dns
|
tags: dns
|
||||||
@@ -52,7 +56,7 @@
|
|||||||
}
|
}
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: hosts_config
|
loop_var: hosts_config
|
||||||
when: ansible_virtualization_type != "docker"
|
when: ansible_virtualization_type != "docker" and ansible_virtualization_type != "container"
|
||||||
|
|
||||||
- name: Ensure NetworkManager does not fiddle DNS
|
- name: Ensure NetworkManager does not fiddle DNS
|
||||||
ini_file:
|
ini_file:
|
||||||
@@ -63,7 +67,7 @@
|
|||||||
backup: yes
|
backup: yes
|
||||||
when: (ansible_os_family == "RedHat" and ansible_distribution_major_version == "7")
|
when: (ansible_os_family == "RedHat" and ansible_distribution_major_version == "7")
|
||||||
notify:
|
notify:
|
||||||
- restart NetworkManager
|
- Restart NetworkManager
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Ensure correct permissions (hosts/resolv.conf)
|
- name: Ensure correct permissions (hosts/resolv.conf)
|
||||||
|
|||||||
@@ -15,21 +15,21 @@
|
|||||||
# /usr/local/bin/dynmotd
|
# /usr/local/bin/dynmotd
|
||||||
#
|
#
|
||||||
|
|
||||||
USER=`whoami`
|
USER=`/usr/bin/env whoami`
|
||||||
HOSTNAME=`uname -n | cut -d. -f1`
|
HOSTNAME=`/usr/bin/env uname -n | /usr/bin/env cut -d. -f1`
|
||||||
IP=`ip route get 1 | awk '{print $NF;exit}'`
|
IP=`/usr/bin/env ip route get 1 | /usr/bin/env grep -Po '(?<=src.)[\w\d.]+'`
|
||||||
NUM_CPU=`lscpu | grep "CPU(s):" | head -n 1 | awk '{print $2}'`
|
IP6=`/usr/bin/env ip -6 addr | /usr/bin/env awk -F '[ \t]+|/' '$3 == "::1" { next;} $3 ~ /^fe80::/ { next ; } /inet6/ {print $3} '`
|
||||||
ROOT=`df -x fuse.gvfs-fuse-daemon -Ph | egrep -i 'root|logvol|vda' | awk '{print $4}' | tr -d '\n'`
|
NUM_CPU=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||||
HOME=`df -x fuse.gvfs-fuse-daemon -Ph | grep home | awk '{print $4}' | tr -d '\n'`
|
#ROOT=`/usr/bin/df / -x fuse.gvfs-fuse-daemon -Ph | /usr/bin/egrep -i 'root|logvol|vda' | awk '{print $4}' | tr -d '\n'`
|
||||||
FILESYSTEMS=`cat /etc/fstab | grep -v '#' | grep -v 'swap' | awk '{if(NF>0) {print $2}}'`
|
#HOME=`/usr/bin/df /home -x fuse.gvfs-fuse-daemon -Ph | grep home | awk '{print $4}' | tr -d '\n'`
|
||||||
BACKUP=`df -x fuse.gvfs-fuse-daemon -Ph | grep backup | awk '{print $4}' | tr -d '\n'`
|
#BACKUP=`/usr/bin/df -x fuse.gvfs-fuse-daemon -Ph | grep backup | awk '{print $4}' | tr -d '\n'`
|
||||||
OS_RELEASE=`awk -F= '$1=="PRETTY_NAME" { print $2 ;}' /etc/os-release | sed -e 's/^"//' -e 's/"$//'`
|
FILESYSTEMS=`cat /etc/fstab | grep -v '#' | grep -v 'swap' | grep -v 'proc' | awk '{if(NF>0) {print $2}}'`
|
||||||
MEMORY=`free -m | grep "Mem" | awk '{print $2,"-",$3,"-",$4}'`
|
MEMORY=`/usr/bin/env free -m | /usr/bin/env grep "Mem" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'`
|
||||||
SWAP=`free -m | grep "Swap" | 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=`ps -Afl | wc -l`
|
PSA=`/usr/bin/env ps -Afl | /usr/bin/env wc -l`
|
||||||
|
|
||||||
# time of day
|
# time of day
|
||||||
HOUR=$(date +"%H")
|
HOUR=$(/usr/bin/env date +"%H")
|
||||||
if [ $HOUR -lt 12 -a $HOUR -ge 0 ]
|
if [ $HOUR -lt 12 -a $HOUR -ge 0 ]
|
||||||
then TIME="morning"
|
then TIME="morning"
|
||||||
elif [ $HOUR -lt 17 -a $HOUR -ge 12 ]
|
elif [ $HOUR -lt 17 -a $HOUR -ge 12 ]
|
||||||
@@ -39,17 +39,17 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#System uptime
|
#System uptime
|
||||||
uptime=`cat /proc/uptime | cut -f1 -d.`
|
uptime=`/usr/bin/env cat /proc/uptime | cut -f1 -d.`
|
||||||
upDays=$((uptime/60/60/24))
|
upDays=$((uptime/60/60/24))
|
||||||
upHours=$((uptime/60/60%24))
|
upHours=$((uptime/60/60%24))
|
||||||
upMins=$((uptime/60%60))
|
upMins=$((uptime/60%60))
|
||||||
upSecs=$((uptime%60))
|
upSecs=$((uptime%60))
|
||||||
|
|
||||||
#System load
|
#System load
|
||||||
LOADAVG=`cat /proc/loadavg`
|
LOADAVG=`/usr/bin/env cat /proc/loadavg`
|
||||||
LOAD1=`echo $LOADAVG | awk {'print $1'}`
|
LOAD1=`echo $LOADAVG | /usr/bin/env awk {'print $1'}`
|
||||||
LOAD5=`echo $LOADAVG | awk {'print $2'}`
|
LOAD5=`echo $LOADAVG | /usr/bin/env awk {'print $2'}`
|
||||||
LOAD15=`echo $LOADAVG | awk {'print $3'}`
|
LOAD15=`echo $LOADAVG | /usr/bin/env awk {'print $3'}`
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\e[7m--- GOOD $TIME $USER ----\e[0m"
|
echo -e "\e[7m--- GOOD $TIME $USER ----\e[0m"
|
||||||
@@ -63,9 +63,19 @@ RESET_COLORS="\e[0m"
|
|||||||
echo -e "
|
echo -e "
|
||||||
===========================================================================
|
===========================================================================
|
||||||
$COLOR_COLUMN- Hostname$RESET_COLORS............: $COLOR_VALUE $HOSTNAME $RESET_COLORS
|
$COLOR_COLUMN- Hostname$RESET_COLORS............: $COLOR_VALUE $HOSTNAME $RESET_COLORS
|
||||||
$COLOR_COLUMN- IP Address (Default)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS
|
{% if common_show_ipv6 == true %}
|
||||||
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE $OS_RELEASE $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
|
||||||
|
{% 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
|
||||||
|
{% 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
|
=========================================================================== $RESET_COLORS
|
||||||
$COLOR_COLUMN- Current user$RESET_COLORS........: $COLOR_VALUE $USER $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- Number of CPU$RESET_COLORS.......: $COLOR_VALUE $NUM_CPU $RESET_COLORS
|
||||||
@@ -74,10 +84,15 @@ echo -e "
|
|||||||
$COLOR_COLUMN- Swap in use$RESET_COLORS.........: $COLOR_VALUE $SWAP (total-used-free) MB $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- 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- 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
|
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
|
done
|
||||||
|
{% endif %}
|
||||||
echo -e "
|
echo -e "
|
||||||
===========================================================================
|
===========================================================================
|
||||||
"
|
"
|
||||||
|
if [ -f /etc/motd ]; then
|
||||||
|
/usr/bin/env cat /etc/motd
|
||||||
|
fi
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
docker_service()::
|
|
||||||
{
|
|
||||||
name: 'docker',
|
|
||||||
image: 'docker:dind',
|
|
||||||
privileged: true,
|
|
||||||
volumes: [{ name: 'dockersock', path: '/var/run' },],
|
|
||||||
},
|
|
||||||
|
|
||||||
email_notification()::
|
|
||||||
{
|
|
||||||
name: 'notify by email',
|
|
||||||
image: 'drillster/drone-email',
|
|
||||||
settings:
|
|
||||||
{ host: 'mail.guise.net.nz',
|
|
||||||
username:
|
|
||||||
{ from_secret: 'EMAIL_USER' },
|
|
||||||
password:
|
|
||||||
{ from_secret: 'EMAIL_PASS' },
|
|
||||||
from: 'drone@guise.net.nz'
|
|
||||||
},
|
|
||||||
when:
|
|
||||||
{ status: [ 'changed', 'failure' ] },
|
|
||||||
},
|
|
||||||
|
|
||||||
test_distro(distribution)::
|
|
||||||
{
|
|
||||||
name: 'Test on %(distribution)s' % { distribution: distribution },
|
|
||||||
volumes: [{ name: 'dockersock', path: '/var/run' },],
|
|
||||||
image: 'guisea/ansible-molecule:latest',
|
|
||||||
commands: [
|
|
||||||
'sleep 10', // give docker enough time to start
|
|
||||||
'mkdir ${DRONE_REPO_NAME}',
|
|
||||||
'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}',
|
|
||||||
'cd ${DRONE_REPO_NAME}',
|
|
||||||
'molecule test'
|
|
||||||
],
|
|
||||||
environment:
|
|
||||||
{ MOLECULE_DISTRO: '%(distribution)s' % { distribution: distribution }
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user