Merge branch 'master' of bitbucket.org:cybercinch/ansible-role-common

This commit is contained in:
2022-03-14 22:49:45 +13:00
6 changed files with 249 additions and 44 deletions

72
.drone.jsonnet Normal file
View File

@@ -0,0 +1,72 @@
// Distros to Test on ;)
local distros = ['centos7',
'centos8',
'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: 'mail.guise.net.nz',
username:
{ from_secret: 'EMAIL_USER' },
password:
{ from_secret: 'EMAIL_PASS' },
from: 'drone@guise.net.nz'
},
when:
{ status: [ 'changed', 'failure' ] },
};
local 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 }
},
};
local gen_pipeline(distro) =
{kind: 'pipeline',
type: 'docker',
name: 'Test on %(distro)s' % { distro: distro },
steps: [
test_distro(distro),
email_notification()],
services: [
docker_service(),
],
volumes:
[{
name: 'dockersock',
temp: {},
},],
};
// Generate the output
[
gen_pipeline(distro)
for distro in distros
]

View File

@@ -1,83 +1,164 @@
---
kind: pipeline
name: centos7
name: Test on centos7
services:
- name: docker
image: docker:dind
- image: docker:dind
name: docker
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
steps:
- name: Test with Molecule centos7
image: guisea/ansible-molecule:latest
volumes:
- name: dockersock
path: /var/run
commands:
- sleep 10 # give docker enough time to start
- 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
- name: notify by email
image: drillster/drone-email
image: guisea/ansible-molecule:latest
name: Test on centos7
volumes:
- name: dockersock
path: /var/run
- image: drillster/drone-email
name: notify by email
settings:
from: drone@guise.net.nz
host: mail.guise.net.nz
username:
from_secret: EMAIL_USER
password:
from_secret: EMAIL_PASS
from: drone@guise.net.nz
username:
from_secret: EMAIL_USER
when:
status: [ changed, failure ]
status:
- changed
- failure
type: docker
volumes:
- name: dockersock
temp: {}
---
kind: pipeline
name: debian10
name: Test on centos8
services:
- name: docker
image: docker:dind
- image: docker:dind
name: docker
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
steps:
- name: Test with Molecule debian10
- 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: Test on centos8
volumes:
- name: dockersock
path: /var/run
commands:
- sleep 10 # give docker enough time to start
- 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
when:
status:
- changed
- failure
type: docker
volumes:
- name: dockersock
temp: {}
---
kind: pipeline
name: Test on debian10
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
- name: notify by email
image: drillster/drone-email
image: guisea/ansible-molecule:latest
name: Test on debian10
volumes:
- name: dockersock
path: /var/run
- image: drillster/drone-email
name: notify by email
settings:
from: drone@guise.net.nz
host: mail.guise.net.nz
username:
from_secret: EMAIL_USER
password:
from_secret: EMAIL_PASS
from: drone@guise.net.nz
username:
from_secret: EMAIL_USER
when:
status: [ changed, failure ]
status:
- changed
- failure
type: docker
volumes:
- name: dockersock
temp: {}
---
kind: pipeline
name: Test on debian11
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: Test on debian11
volumes:
- name: dockersock
path: /var/run
- 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
when:
status:
- changed
- failure
type: docker
volumes:
- name: dockersock
temp: {}

View File

@@ -16,8 +16,6 @@ common_grub_timeout: 5
postfix_configure: false
common_packages:
- libselinux-python
- MySQL-python
- nano
- git
- htop

5
tasks/common.yml Normal file
View File

@@ -0,0 +1,5 @@
---
- include_tasks: networking.yml
- include_tasks: communication.yml
- include_tasks: grub.yml
- include_tasks: motd.yml

View File

@@ -1,2 +1,9 @@
---
- include: "{{ ansible_os_family }}.yml"
- name: Include tasks only if one of the files exist, otherwise skip the task
include_tasks: '{{ item }}'
vars:
params:
files:
- '{{ ansible_os_family }}.yml'
- 'common.yml'
loop: "{{ q('first_found', params, errors='ignore') }}"

42
utils.libsonnet Normal file
View File

@@ -0,0 +1,42 @@
{
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 }
},
},
}