Compare commits

...

No commits in common. "main" and "docs" have entirely different histories.
main ... docs

22 changed files with 452 additions and 941 deletions

View File

@ -1,159 +0,0 @@
local PipelineLinting = {
kind: 'pipeline',
name: 'linting',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'ansible-later',
image: 'thegeeklab/ansible-later',
commands: [
'ansible-later',
],
},
{
name: 'python-format',
image: 'python:3.11',
environment: {
PY_COLORS: 1,
},
commands: [
'pip install -qq yapf',
'[ -z "$(find . -type f -name *.py)" ] || (yapf -rd ./)',
],
},
{
name: 'python-flake8',
image: 'python:3.11',
environment: {
PY_COLORS: 1,
},
commands: [
'pip install -qq flake8',
'flake8',
],
},
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
};
local PipelineDeployment(scenario='centos7') = {
kind: 'pipeline',
name: 'testing-' + scenario,
platform: {
os: 'linux',
arch: 'amd64',
},
concurrency: {
limit: 1,
},
workspace: {
base: '/drone/src',
path: '${DRONE_REPO_NAME}',
},
steps: [
{
name: 'ansible-molecule',
image: 'thegeeklab/molecule:4',
environment: {
HCLOUD_TOKEN: { from_secret: 'hcloud_token' },
},
commands: [
'molecule test -s ' + scenario,
],
},
],
depends_on: [
'linting',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**'],
},
};
local PipelineDocumentation = {
kind: 'pipeline',
name: 'documentation',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'generate',
image: 'thegeeklab/ansible-doctor',
environment: {
ANSIBLE_DOCTOR_LOG_LEVEL: 'INFO',
ANSIBLE_DOCTOR_FORCE_OVERWRITE: true,
ANSIBLE_DOCTOR_EXCLUDE_FILES: 'molecule/',
ANSIBLE_DOCTOR_TEMPLATE: 'hugo-book',
ANSIBLE_DOCTOR_ROLE_NAME: '${DRONE_REPO_NAME#*.}',
ANSIBLE_DOCTOR_OUTPUT_DIR: '_docs/',
},
},
{
name: 'publish',
image: 'plugins/gh-pages',
settings: {
remote_url: 'https://gitea.rknet.org/ansible/${DRONE_REPO_NAME}',
netrc_machine: 'gitea.rknet.org',
username: { from_secret: 'gitea_username' },
password: { from_secret: 'gitea_token' },
pages_directory: '_docs/',
target_branch: 'docs',
},
when: {
ref: ['refs/heads/main'],
},
},
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
depends_on: [
'testing-centos7',
],
};
local PipelineNotification = {
kind: 'pipeline',
name: 'notification',
platform: {
os: 'linux',
arch: 'amd64',
},
clone: {
disable: true,
},
steps: [
{
name: 'matrix',
image: 'thegeeklab/drone-matrix',
settings: {
homeserver: { from_secret: 'matrix_homeserver' },
roomid: { from_secret: 'matrix_roomid' },
template: 'Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}',
username: { from_secret: 'matrix_username' },
password: { from_secret: 'matrix_password' },
},
},
],
depends_on: [
'documentation',
],
trigger: {
status: ['success', 'failure'],
ref: ['refs/heads/main', 'refs/tags/**'],
},
};
[
PipelineLinting,
PipelineDeployment(scenario='centos7'),
PipelineDocumentation,
PipelineNotification,
]

View File

@ -1,152 +0,0 @@
---
kind: pipeline
name: linting
platform:
os: linux
arch: amd64
steps:
- name: ansible-later
image: thegeeklab/ansible-later
commands:
- ansible-later
- name: python-format
image: python:3.11
commands:
- pip install -qq yapf
- "[ -z \"$(find . -type f -name *.py)\" ] || (yapf -rd ./)"
environment:
PY_COLORS: 1
- name: python-flake8
image: python:3.11
commands:
- pip install -qq flake8
- flake8
environment:
PY_COLORS: 1
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
---
kind: pipeline
name: testing-centos7
platform:
os: linux
arch: amd64
concurrency:
limit: 1
workspace:
base: /drone/src
path: ${DRONE_REPO_NAME}
steps:
- name: ansible-molecule
image: thegeeklab/molecule:4
commands:
- molecule test -s centos7
environment:
HCLOUD_TOKEN:
from_secret: hcloud_token
trigger:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- linting
---
kind: pipeline
name: documentation
platform:
os: linux
arch: amd64
steps:
- name: generate
image: thegeeklab/ansible-doctor
environment:
ANSIBLE_DOCTOR_EXCLUDE_FILES: molecule/
ANSIBLE_DOCTOR_FORCE_OVERWRITE: true
ANSIBLE_DOCTOR_LOG_LEVEL: INFO
ANSIBLE_DOCTOR_OUTPUT_DIR: _docs/
ANSIBLE_DOCTOR_ROLE_NAME: ${DRONE_REPO_NAME#*.}
ANSIBLE_DOCTOR_TEMPLATE: hugo-book
- name: publish
image: plugins/gh-pages
settings:
netrc_machine: gitea.rknet.org
pages_directory: _docs/
password:
from_secret: gitea_token
remote_url: https://gitea.rknet.org/ansible/${DRONE_REPO_NAME}
target_branch: docs
username:
from_secret: gitea_username
when:
ref:
- refs/heads/main
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- testing-centos7
---
kind: pipeline
name: notification
platform:
os: linux
arch: amd64
clone:
disable: true
steps:
- name: matrix
image: thegeeklab/drone-matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
template: "Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}"
username:
from_secret: matrix_username
trigger:
ref:
- refs/heads/main
- refs/tags/**
status:
- success
- failure
depends_on:
- documentation
---
kind: signature
hmac: d1a1c886c75fa6074249c12d17463203821175c7924e6549d7a5414f29d2f16c
...

13
.gitignore vendored
View File

@ -1,13 +0,0 @@
# ---> Ansible
*.retry
filter/plugins/
library
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# ---> Docs
/_docs

View File

@ -1,19 +0,0 @@
---
ansible:
custom_modules:
- iptables_raw
- openssl_pkcs12
- proxmox_kvm
- ucr
- corenetworks_dns
- corenetworks_token
rules:
exclude_files:
- molecule/
- "LICENSE*"
- "**/*.md"
- "**/*.ini"
exclude_filter:
- LINT0009

21
LICENSE
View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2022 Robert Kaussow <mail@thegeeklab.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,12 +0,0 @@
# xoxys.droneci
[![Build Status](https://img.shields.io/drone/build/ansible/xoxys.droneci?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.droneci)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
Setup [Drone CI](https://drone.io/) base server. Drone is a Continuous Delivery system built on container technology. Drone uses a simple YAML configuration file, a superset of docker-compose, to define and execute Pipelines inside Docker containers.
You can find the full documentation at [https://galaxy.geekdocs.de](https://galaxy.geekdocs.de/roles/cloud/droneci/).
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

View File

@ -1,108 +0,0 @@
---
droneci_version: 1.6.0
droneci_image: "drone/drone:{{ droneci_version }}"
droneci_service_directory: /var/lib/docker/services/droneci
droneci_docker_socket_path: /var/run/docker.sock
droneci_container_name: droneci
droneci_restart_policy: always
droneci_service_stopped: False
droneci_host: http://localhost
droneci_secret: myveryownsecret
# @var droneci_license_key:description Path to the license key file
# @var droneci_license_key: $ "_unset_"
droneci_exposed_ports:
- "127.0.0.1:8080:80"
# @var droneci_volumes:description: > Define required docker volumes.
# If you don't use sqlite you could remove the default volume. To enable a Drone licences
# you will need to configure a bind mount to `/etc/drone.key`.
# @end
# @var droneci_volumes:example: >
# droneci_volumes:
# # Instead of the name you could specify a path on the container host system,
# # but you also have to enable bind mount for this volume
# - name: data
# # target location inside the container
# dest: /var/lib/drone
# # enable bind mount, if false volume will be configured as named volume
# # keep in mind you MUST set bind in any case
# bind: True
# @end
droneci_volumes:
- name: data
dest: /var/lib/drone
bind: False
# @var droneci_networks:example: >
# droneci_networks:
# - name: default
# # optional network driver, defaults to 'bride'
# driver: host
# @end
droneci_networks:
- name: default
droneci_networks_applied:
- default
# @var droneci_memory_limit: $ "_unset_"
# @var droneci_memory_limit:example: $ "512m"
# @var droneci_memory_reservation: $ "_unset_"
# @var droneci_memory_reservation:example: $ "256m"
droneci_privileged: False
droneci_db_type: sqlite
droneci_db_server: localhost
droneci_db_port: 5432
droneci_db_name: droneci
droneci_db_user: pgdroneci
droneci_db_password: secure
droneci_db_ssl_mode: disable
# @var droneci_db_secret:description: >
# Drone supports aesgcm encryption of secrets stored in the database. You must enable encryption
# before any secrets are stored in the database! You can generate an encryption key with e.g.
# `openssl rand -hex 16`.
# @end
# @var droneci_db_secret: $ "_unset_"
# @var droneci_db_secret:example: $ "0c549fd39ae397333761d2cb0c53c219"
# @var droneci_scm_provider:description: SCM provider to use with Drone (gitea|github)
droneci_scm_provider: none
## required gitea settings
droneci_gitea_server: http://my-git.example.com
droneci_gitea_skip_verify: False
# @var droneci_gitea_oauth_client_id:example: $ "1111-222-33333-44444"
# @var droneci_gitea_oauth_client_id: $ "_unset_"
# @var droneci_gitea_oauth_client_secret:example: $ "1234abcd5678efgh"
# @var droneci_gitea_oauth_client_secret: $ "_unset_"
## required github settings
# @var droneci_github_client_id: $ "_unset_"
# @var droneci_github_client_secret: $ "_unset_"
# @var droneci_repository_filter:description: >
# Optional comma-separated list of accounts, used to limit which repositories are
# syncronized between your source control management system and Drone.
# @end
droneci_repository_filter: []
droneci_user_filter: []
# @var droneci_admin_user: $ "_unset_"
# @var droneci_http_proxy: $ "_unset_"
# @var droneci_https_proxy: $ "_unset_"
droneci_prometheus_anonymous_access: False
# @var droneci_no_proxy: $ ["drone-server", "drone-agent"]
droneci_no_proxy: []
droneci_extra_hosts: []

452
index.md Normal file
View File

@ -0,0 +1,452 @@
---
title: droneci
type: docs
---
[![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.droneci) [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.droneci?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.droneci) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/ansible/xoxys.droneci/src/branch/main/LICENSE)
Setup [Drone CI](https://drone.io/) base server. Drone is a Continuous Delivery system built on container technology. Drone uses a simple YAML configuration file, a superset of docker-compose, to define and execute Pipelines inside Docker containers.
<!--more-->
- [Default Variables](#default-variables)
- [droneci_admin_user](#droneci_admin_user)
- [droneci_container_name](#droneci_container_name)
- [droneci_db_name](#droneci_db_name)
- [droneci_db_password](#droneci_db_password)
- [droneci_db_port](#droneci_db_port)
- [droneci_db_secret](#droneci_db_secret)
- [droneci_db_server](#droneci_db_server)
- [droneci_db_ssl_mode](#droneci_db_ssl_mode)
- [droneci_db_type](#droneci_db_type)
- [droneci_db_user](#droneci_db_user)
- [droneci_docker_socket_path](#droneci_docker_socket_path)
- [droneci_exposed_ports](#droneci_exposed_ports)
- [droneci_extra_hosts](#droneci_extra_hosts)
- [droneci_gitea_oauth_client_id](#droneci_gitea_oauth_client_id)
- [droneci_gitea_oauth_client_secret](#droneci_gitea_oauth_client_secret)
- [droneci_gitea_server](#droneci_gitea_server)
- [droneci_gitea_skip_verify](#droneci_gitea_skip_verify)
- [droneci_github_client_id](#droneci_github_client_id)
- [droneci_github_client_secret](#droneci_github_client_secret)
- [droneci_host](#droneci_host)
- [droneci_http_proxy](#droneci_http_proxy)
- [droneci_https_proxy](#droneci_https_proxy)
- [droneci_image](#droneci_image)
- [droneci_license_key](#droneci_license_key)
- [droneci_memory_limit](#droneci_memory_limit)
- [droneci_memory_reservation](#droneci_memory_reservation)
- [droneci_networks](#droneci_networks)
- [droneci_networks_applied](#droneci_networks_applied)
- [droneci_no_proxy](#droneci_no_proxy)
- [droneci_privileged](#droneci_privileged)
- [droneci_prometheus_anonymous_access](#droneci_prometheus_anonymous_access)
- [droneci_repository_filter](#droneci_repository_filter)
- [droneci_restart_policy](#droneci_restart_policy)
- [droneci_scm_provider](#droneci_scm_provider)
- [droneci_secret](#droneci_secret)
- [droneci_service_directory](#droneci_service_directory)
- [droneci_service_stopped](#droneci_service_stopped)
- [droneci_user_filter](#droneci_user_filter)
- [droneci_version](#droneci_version)
- [droneci_volumes](#droneci_volumes)
- [Dependencies](#dependencies)
---
## Default Variables
### droneci_admin_user
#### Default value
```YAML
droneci_admin_user: _unset_
```
### droneci_container_name
#### Default value
```YAML
droneci_container_name: droneci
```
### droneci_db_name
#### Default value
```YAML
droneci_db_name: droneci
```
### droneci_db_password
#### Default value
```YAML
droneci_db_password: secure
```
### droneci_db_port
#### Default value
```YAML
droneci_db_port: 5432
```
### droneci_db_secret
Drone supports aesgcm encryption of secrets stored in the database. You must enable encryption before any secrets are stored in the database! You can generate an encryption key with e.g. `openssl rand -hex 16`.
#### Default value
```YAML
droneci_db_secret: _unset_
```
#### Example usage
```YAML
droneci_db_secret: 0c549fd39ae397333761d2cb0c53c219
```
### droneci_db_server
#### Default value
```YAML
droneci_db_server: localhost
```
### droneci_db_ssl_mode
#### Default value
```YAML
droneci_db_ssl_mode: disable
```
### droneci_db_type
#### Default value
```YAML
droneci_db_type: sqlite
```
### droneci_db_user
#### Default value
```YAML
droneci_db_user: pgdroneci
```
### droneci_docker_socket_path
#### Default value
```YAML
droneci_docker_socket_path: /var/run/docker.sock
```
### droneci_exposed_ports
#### Default value
```YAML
droneci_exposed_ports:
- 127.0.0.1:8080:80
```
### droneci_extra_hosts
#### Default value
```YAML
droneci_extra_hosts: []
```
### droneci_gitea_oauth_client_id
#### Default value
```YAML
droneci_gitea_oauth_client_id: _unset_
```
#### Example usage
```YAML
droneci_gitea_oauth_client_id: 1111-222-33333-44444
```
### droneci_gitea_oauth_client_secret
#### Default value
```YAML
droneci_gitea_oauth_client_secret: _unset_
```
#### Example usage
```YAML
droneci_gitea_oauth_client_secret: 1234abcd5678efgh
```
### droneci_gitea_server
#### Default value
```YAML
droneci_gitea_server: http://my-git.example.com
```
### droneci_gitea_skip_verify
#### Default value
```YAML
droneci_gitea_skip_verify: false
```
### droneci_github_client_id
#### Default value
```YAML
droneci_github_client_id: _unset_
```
### droneci_github_client_secret
#### Default value
```YAML
droneci_github_client_secret: _unset_
```
### droneci_host
#### Default value
```YAML
droneci_host: http://localhost
```
### droneci_http_proxy
#### Default value
```YAML
droneci_http_proxy: _unset_
```
### droneci_https_proxy
#### Default value
```YAML
droneci_https_proxy: _unset_
```
### droneci_image
#### Default value
```YAML
droneci_image: drone/drone:{{ droneci_version }}
```
### droneci_license_key
#### Default value
```YAML
droneci_license_key: _unset_
```
### droneci_memory_limit
#### Default value
```YAML
droneci_memory_limit: _unset_
```
#### Example usage
```YAML
droneci_memory_limit: 512m
```
### droneci_memory_reservation
#### Default value
```YAML
droneci_memory_reservation: _unset_
```
#### Example usage
```YAML
droneci_memory_reservation: 256m
```
### droneci_networks
#### Default value
```YAML
droneci_networks:
- name: default
```
#### Example usage
```YAML
droneci_networks:
- name: default
# optional network driver, defaults to 'bride'
driver: host
```
### droneci_networks_applied
#### Default value
```YAML
droneci_networks_applied:
- default
```
### droneci_no_proxy
#### Default value
```YAML
droneci_no_proxy:
- drone-server
- drone-agent
```
### droneci_privileged
#### Default value
```YAML
droneci_privileged: false
```
### droneci_prometheus_anonymous_access
#### Default value
```YAML
droneci_prometheus_anonymous_access: false
```
### droneci_repository_filter
Optional comma-separated list of accounts, used to limit which repositories are syncronized between your source control management system and Drone.
#### Default value
```YAML
droneci_repository_filter: []
```
### droneci_restart_policy
#### Default value
```YAML
droneci_restart_policy: always
```
### droneci_scm_provider
SCM provider to use with Drone (gitea|github)
#### Default value
```YAML
droneci_scm_provider: none
```
### droneci_secret
#### Default value
```YAML
droneci_secret: myveryownsecret
```
### droneci_service_directory
#### Default value
```YAML
droneci_service_directory: /var/lib/docker/services/droneci
```
### droneci_service_stopped
#### Default value
```YAML
droneci_service_stopped: false
```
### droneci_user_filter
#### Default value
```YAML
droneci_user_filter: []
```
### droneci_version
#### Default value
```YAML
droneci_version: 1.6.0
```
### droneci_volumes
> Define required docker volumes.
#### Default value
```YAML
droneci_volumes:
- name: data
dest: /var/lib/drone
bind: false
```
#### Example usage
```YAML
droneci_volumes:
# Instead of the name you could specify a path on the container host system,
# but you also have to enable bind mount for this volume
- name: data
# target location inside the container
dest: /var/lib/drone
# enable bind mount, if false volume will be configured as named volume
# keep in mind you MUST set bind in any case
bind: True
```
## Dependencies
None.

View File

@ -1,30 +0,0 @@
# Standards: 0.2
---
galaxy_info:
# @meta author:value: [Robert Kaussow](https://gitea.rknet.org/xoxys)
author: Robert Kaussow <mail@thegeeklab.de>
namespace: xoxys
role_name: droneci
# @meta description: >
# [![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.droneci)
# [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.droneci?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.droneci)
# [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/ansible/xoxys.droneci/src/branch/main/LICENSE)
#
# Setup [Drone CI](https://drone.io/) base server. Drone is a Continuous Delivery system built on container technology.
# Drone uses a simple YAML configuration file, a superset of docker-compose, to define and execute Pipelines inside Docker containers.
# @end
description: Setup Drone CI base server
license: MIT
min_ansible_version: 2.10
platforms:
- name: EL
versions:
- 7
galaxy_tags:
- drone ci
- ci
- devops
dependencies: []
collections:
- xoxys.general
- community.general

View File

@ -1,16 +0,0 @@
---
- name: Converge
hosts: all
environment:
PYTHONPATH: /opt/python2/ansible-deps/lib/python2.7/site-packages
vars:
dockerengine_packages_extra:
- epel-release
- python-pip
- python-virtualenv
droneci_admin_user: dummy
droneci_service_stopped: True
roles:
- role: xoxys.docker_engine
- role: xoxys.droneci

View File

@ -1,120 +0,0 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
vars:
ssh_port: 22
ssh_user: root
ssh_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
tasks:
- name: Create SSH key
user:
name: "{{ lookup('env', 'USER') }}"
generate_ssh_key: true
ssh_key_file: "{{ ssh_path }}"
force: true
register: generated_ssh_key
- name: Register the SSH key name
set_fact:
ssh_key_name: "molecule-generated-{{ 12345 | random | to_uuid }}"
- name: Register SSH key for test instance(s)
hcloud_ssh_key:
name: "{{ ssh_key_name }}"
public_key: "{{ generated_ssh_key.ssh_public_key }}"
state: present
- name: Create molecule instance(s)
hcloud_server:
name: "{{ item.name }}"
server_type: "{{ item.server_type }}"
ssh_keys:
- "{{ ssh_key_name }}"
image: "{{ item.image }}"
location: "{{ item.location | default(omit) }}"
datacenter: "{{ item.datacenter | default(omit) }}"
user_data: "{{ item.user_data | default(omit) }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: present
register: server
loop: "{{ molecule_yml.platforms }}"
async: 7200
poll: 0
- name: Wait for instance(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
loop: "{{ server.results }}"
- name: Create volume(s)
hcloud_volume:
name: "{{ item.name }}"
server: "{{ item.name }}"
location: "{{ item.location | default(omit) }}"
size: "{{ item.volume_size | default(10) }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: "present"
loop: "{{ molecule_yml.platforms }}"
when: item.volume | default(False) | bool
register: volumes
async: 7200
poll: 0
- name: Wait for volume(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_volumes
until: hetzner_volumes.finished
retries: 300
when: volumes.changed
loop: "{{ volumes.results }}"
# Mandatory configuration for Molecule to function.
- name: Populate instance config dict
set_fact:
instance_conf_dict:
{
"instance": "{{ item.hcloud_server.name }}",
"ssh_key_name": "{{ ssh_key_name }}",
"address": "{{ item.hcloud_server.ipv4_address }}",
"user": "{{ ssh_user }}",
"port": "{{ ssh_port }}",
"identity_file": "{{ ssh_path }}",
"volume": "{{ item.item.item.volume | default(False) | bool }}",
}
loop: "{{ hetzner_jobs.results }}"
register: instance_config_dict
when: server.changed | bool
- name: Convert instance config dict to a list
set_fact:
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
when: server.changed | bool
- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_nice_yaml(indent=2) }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool
- name: Wait for SSH
wait_for:
port: "{{ ssh_port }}"
host: "{{ item.address }}"
search_regex: SSH
delay: 10
loop: "{{ lookup('file', molecule_instance_config) | from_yaml }}"
- name: Wait for VM to settle down
pause:
seconds: 30

View File

@ -1,78 +0,0 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
tasks:
- name: Check existing instance config file
stat:
path: "{{ molecule_instance_config }}"
register: cfg
- name: Populate the instance config
set_fact:
instance_conf: "{{ (lookup('file', molecule_instance_config) | from_yaml) if cfg.stat.exists else [] }}"
- name: Destroy molecule instance(s)
hcloud_server:
name: "{{ item.instance }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: absent
register: server
loop: "{{ instance_conf }}"
async: 7200
poll: 0
- name: Wait for instance(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
loop: "{{ server.results }}"
- pause:
seconds: 5
- name: Destroy volume(s)
hcloud_volume:
name: "{{ item.instance }}"
server: "{{ item.instance }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: "absent"
register: volumes
loop: "{{ instance_conf }}"
when: item.volume | default(False) | bool
async: 7200
poll: 0
- name: Wait for volume(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_volumes
until: hetzner_volumes.finished
retries: 300
when: volumes.changed
loop: "{{ volumes.results }}"
- name: Remove registered SSH key
hcloud_ssh_key:
name: "{{ instance_conf[0].ssh_key_name }}"
state: absent
when: (instance_conf | default([])) | length > 0
# Mandatory configuration for Molecule to function.
- name: Populate instance config
set_fact:
instance_conf: {}
- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_nice_yaml(indent=2) }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool

View File

@ -1,24 +0,0 @@
---
dependency:
name: galaxy
options:
role-file: molecule/requirements.yml
requirements-file: molecule/requirements.yml
env:
ANSIBLE_GALAXY_DISPLAY_PROGRESS: "false"
driver:
name: delegated
platforms:
- name: centos7-droneci
image: centos-7
server_type: cx11
lint: |
/usr/local/bin/flake8
provisioner:
name: ansible
env:
ANSIBLE_FILTER_PLUGINS: ${ANSIBLE_FILTER_PLUGINS:-./plugins/filter}
ANSIBLE_LIBRARY: ${ANSIBLE_LIBRARY:-./library}
log: False
verifier:
name: testinfra

View File

@ -1,15 +0,0 @@
---
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Bootstrap python for Ansible
raw: |
command -v python3 python || (
(test -e /usr/bin/dnf && sudo dnf install -y python3) ||
(test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
(test -e /usr/bin/yum && sudo yum -y -qq install python3) ||
echo "Warning: Python not boostrapped due to unknown platform."
)
become: true
changed_when: false

View File

@ -1,13 +0,0 @@
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")
def test_droneci_compose_file(host):
f = host.file('/var/lib/docker/services/droneci/docker-compose.yml')
assert f.exists

View File

@ -1 +0,0 @@
centos7

View File

@ -1,3 +0,0 @@
[pytest]
filterwarnings =
ignore::DeprecationWarning

View File

@ -1,10 +0,0 @@
---
collections:
- name: https://gitea.rknet.org/ansible/xoxys.general/releases/download/v2.1.1/xoxys-general-2.1.1.tar.gz
- name: community.general
roles:
- src: https://gitea.rknet.org/ansible/xoxys.docker_engine.git
name: xoxys.docker_engine
scm: git
version: main

View File

@ -1,12 +0,0 @@
[flake8]
ignore = D100, D101, D102, D103, D105, D107, E402, W503
max-line-length = 99
inline-quotes = double
exclude = .git,.tox,__pycache__,build,dist,tests,*.pyc,*.egg-info,.cache,.eggs,env*
[yapf]
based_on_style = google
column_limit = 99
dedent_closing_brackets = true
coalesce_brackets = true
split_before_logical_operator = true

View File

@ -1,2 +0,0 @@
---
- include_tasks: setup.yml

View File

@ -1,33 +0,0 @@
---
- block:
- name: Ensure service directory exists
file:
path: "{{ droneci_service_directory }}"
state: directory
mode: 0755
- name: Deploy compose file to '{{ droneci_service_directory }}'
template:
src: "services/droneci_compose.yml.j2"
dest: "{{ droneci_service_directory }}/docker-compose.yml"
owner: root
group: root
mode: 0640
validate: "docker-compose -f %s config -q"
- name: Copy license key file is defined
copy:
src: "{{ droneci_license_key }}"
dest: "{{ droneci_service_directory }}/{{ droneci_license_key | basename }}"
mode: 0600
when: droneci_license_key is defined
- name: Ensure Drone is up and running
docker_compose:
project_src: "{{ droneci_service_directory }}"
pull: yes
remove_orphans: yes
stopped: "{{ droneci_service_stopped }}"
state: present
become: True
become_user: root

View File

@ -1,100 +0,0 @@
#jinja2:lstrip_blocks: True
{{ ansible_managed | comment }}
version: "2.4"
services:
droneci:
container_name: {{ droneci_container_name }}
image: {{ droneci_image }}
restart: {{ droneci_restart_policy }}
{% if droneci_exposed_ports | default([]) %}
ports:
{% for port in droneci_exposed_ports %}
- {{ port | quote }}
{% endfor %}
{% endif %}
{% if droneci_volumes | default([]) %}
volumes:
{% for volume in droneci_volumes %}
- "{{ volume.name }}:{{ volume.dest }}"
{% endfor %}
{% endif %}
{% if droneci_networks_applied | default([]) %}
networks:
{% for network in droneci_networks_applied %}
- {{ network }}
{% endfor %}
{% endif %}
{% if droneci_extra_hosts | default([]) %}
extra_hosts:
{% for host in droneci_extra_hosts %}
- {{ host | quote }}
{% endfor %}
{% endif %}
privileged: {{ droneci_privileged | bool | lower }}
environment:
- DRONE_SERVER_HOST={{ droneci_host | urlsplit('hostname') }}
- DRONE_SERVER_PROTO={{ droneci_host | urlsplit('scheme') }}
- DRONE_AGENTS_ENABLED=true
- DRONE_RPC_SECRET={{ droneci_secret }}
- DRONE_USER_CREATE=username:{{ droneci_admin_user }},admin:true
{% if droneci_user_filter is defined and droneci_user_filter | length > 0 %}
- DRONE_USER_FILTER={{ droneci_user_filter | join(",") }}
{% endif %}
{% if droneci_repository_filter is defined and droneci_repository_filter | length > 0 %}
- DRONE_REPOSITORY_FILTER={{ droneci_repository_filter | join(",") }}
{% endif %}
- DRONE_LOGS_COLOR=true
- DRONE_LOGS_PRETTY=true
- DRONE_TLS_AUTOCERT=false
- DRONE_DATADOG_ENABLED=false
- DRONE_DATADOG_ENDPOINT=dummy
- DRONE_DATADOG_TOKEN=dummy
- DRONE_PROMETHEUS_ANONYMOUS_ACCESS={{ droneci_prometheus_anonymous_access | bool | lower }}
{% if droneci_db_secret is defined %}
- DRONE_DATABASE_SECRET={{ droneci_db_secret }}
{% endif %}
{% if droneci_db_type == "pgsql" %}
- DRONE_DATABASE_DRIVER=postgres
- DRONE_DATABASE_DATASOURCE=postgres://{{ droneci_db_user }}:{{ droneci_db_password }}@{{ droneci_db_server }}/{{ droneci_db_name }}?sslmode={{ droneci_db_ssl_mode }}
{% endif %}
{% if droneci_scm_provider | lower == "gitea" %}
- DRONE_GITEA_SERVER={{ droneci_gitea_server }}
- DRONE_GITEA_SKIP_VERIFY={{ droneci_gitea_skip_verify | lower }}
- DRONE_GITEA_CLIENT_ID={{ droneci_gitea_oauth_client_id }}
- DRONE_GITEA_CLIENT_SECRET={{ droneci_gitea_oauth_client_secret }}
{% elif droneci_scm_provider | lower == "github" %}
- DRONE_GITHUB_CLIENT_ID={{ droneci_github_client_id }}
- DRONE_GITHUB_CLIENT_SECRET={{ droneci_github_client_secret }}
{% endif %}
{% if droneci_http_proxy is defined %}
- HTTP_PROXY={{ droneci_http_proxy | join(',') }}
- http_proxy={{ droneci_http_proxy | join(',') }}
{% endif %}
{% if droneci_https_proxy is defined %}
- HTTPS_PROXY={{ droneci_https_proxy | join(',') }}
- https_proxy={{ droneci_https_proxy | join(',') }}
{% endif %}
- NO_PROXY={{ droneci_no_proxy | join(',') }}
- no_proxy={{ droneci_no_proxy | join(',') }}
{% if droneci_memory_limit is defined %}
mem_limit: {{ droneci_memory_limit }}
{% endif %}
{% if droneci_memory_reservation is defined %}
mem_reservation: {{ droneci_memory_reservation }}
{% endif %}
{% if droneci_volumes | default([]) | rejectattr("bind") | list | length > 0 %}
volumes:
{% for volume in droneci_volumes | rejectattr("bind") %}
{{ volume.name }}:
{% endfor %}
{% endif %}
{% if droneci_networks | default([]) | length > 0 %}
networks:
{% for network in droneci_networks %}
{{ network.name }}:
driver: {{ network.backend | default("bridge") }}
{% endfor %}
{% endif %}