// 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' } }; local test_distro(distribution) = { name: 'Molecule 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', node: {linodrone: true}, name: 'Test on %(distro)s' % { distro: distro }, steps: [test_distro(distro)], services: [docker_service()], volumes: [{ name: 'dockersock', temp: {}, },], depends_on: ['runners'] }; // Generate the output [ {kind: 'pipeline', type: 'docker', name: 'runners', steps: [{name: 'Provision with terraform', image: 'hashicorp/terraform:1.1.7', commands: ['cd terraform', 'terraform init', 'terraform plan -out /data/runners.plan', 'terraform apply /data/runners.plan', ], environment: { TF_VAR_root_pass: {from_secret: 'root_pass'}, TF_VAR_linode_api_token: {from_secret: 'linode_api_token'}, TF_VAR_ssh_pubkey: {from_secret: 'TF_VAR_ssh_pubkey'}, }, volumes: [{ name: 'terraform-data', path: '/data' },], },], volumes: [{ name: 'terraform-data', host: { path: '/mnt/nfs/swarm/runners'}, }], }, gen_pipeline('centos7'), gen_pipeline('centos8'), gen_pipeline('rockylinux8'), gen_pipeline('debian10'), gen_pipeline('debian11'), {kind: 'pipeline', type: 'docker', name: 'Notify', steps: [email_notification()], when: { status: [ 'success', 'failure' ] }, depends_on: ['Test on %(distro)s' % { distro: distro } for distro in distros] } ]