Compare commits

...

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

12 changed files with 156 additions and 468 deletions

View File

@ -1,124 +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 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: [
'linting',
],
};
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,
PipelineDocumentation,
PipelineNotification,
]

View File

@ -1,120 +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: 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:
- linting
---
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: 317520af3f615c8c67504ebd3cec04049f846652b9d8a49bf8cf354d2500f076
...

13
.gitignore vendored
View File

@ -1,13 +0,0 @@
# ---> Ansible
*.retry
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,10 +0,0 @@
# xoxys.hcloud_server
[![Build Status](https://img.shields.io/drone/build/ansible/xoxys.hcloud_server?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.hcloud_server)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](LICENSE)
You can find the full documentation at [https://galaxy.geekdocs.de](https://galaxy.geekdocs.de/roles/cloud/hcloud_server/).
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

View File

@ -1,47 +0,0 @@
---
hcloud_server: {}
# @var hcloud_server: example: >
# hcloud_server:
# name: my-server
# type: cx11
# ssh_keys: "{{ hcloud_server_default_ssh_keys }}"
# image: "{{ hcloud_server_default_image }}"
# location: "{{ hcloud_server_default_location }}"
# backup: "{{ hcloud_server_default_backup }}"
# protection: "{{ hcloud_server_default_protection }}"
# api_token: "{{ hcloud_server_default_api_token }}"
# labels:
# os: redhat
# @end
hcloud_server_default_image: centos-7
hcloud_server_default_location: nbg1
hcloud_server_default_protection: False
hcloud_server_default_backup: False
hcloud_server_default_ssh_keys: []
# @var hcloud_server_default_api_token: $ "_unset_"
hcloud_server_networks: []
# @var hcloud_server_networks:example: >
# hcloud_server_networks:
# - name: network-1
# ip: 10.0.0.1
# state: present
# @end
hcloud_server_volumes: []
# @var hcloud_server_volumes:example: >
# hcloud_server_volumes:
# - name: my-volume
# size: 10
# state: present
# @end
hcloud_server_rdns: []
# @var hcloud_server_rdns:example: >
# hcloud_server_rdns:
# - addr: 1.2.3.4
# ptr: example.com
# state: present
# @end

156
index.md Normal file
View File

@ -0,0 +1,156 @@
---
title: hcloud_server
type: docs
---
[![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.hcloud_server) [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.hcloud_server?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.hcloud_server) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.hcloud_server/src/branch/main/LICENSE)
Manage Hetzner Cloud server instances
<!--more-->
- [Default Variables](#default-variables)
- [hcloud_server](#hcloud_server)
- [hcloud_server_default_api_token](#hcloud_server_default_api_token)
- [hcloud_server_default_backup](#hcloud_server_default_backup)
- [hcloud_server_default_image](#hcloud_server_default_image)
- [hcloud_server_default_location](#hcloud_server_default_location)
- [hcloud_server_default_protection](#hcloud_server_default_protection)
- [hcloud_server_default_ssh_keys](#hcloud_server_default_ssh_keys)
- [hcloud_server_networks](#hcloud_server_networks)
- [hcloud_server_rdns](#hcloud_server_rdns)
- [hcloud_server_volumes](#hcloud_server_volumes)
- [Dependencies](#dependencies)
---
## Default Variables
### hcloud_server
#### Default value
```YAML
hcloud_server: {}
```
#### Example usage
```YAML
hcloud_server:
name: my-server
type: cx11
ssh_keys: "{{ hcloud_server_default_ssh_keys }}"
image: "{{ hcloud_server_default_image }}"
location: "{{ hcloud_server_default_location }}"
backup: "{{ hcloud_server_default_backup }}"
protection: "{{ hcloud_server_default_protection }}"
api_token: "{{ hcloud_server_default_api_token }}"
labels:
os: redhat
```
### hcloud_server_default_api_token
#### Default value
```YAML
hcloud_server_default_api_token: _unset_
```
### hcloud_server_default_backup
#### Default value
```YAML
hcloud_server_default_backup: false
```
### hcloud_server_default_image
#### Default value
```YAML
hcloud_server_default_image: centos-7
```
### hcloud_server_default_location
#### Default value
```YAML
hcloud_server_default_location: nbg1
```
### hcloud_server_default_protection
#### Default value
```YAML
hcloud_server_default_protection: false
```
### hcloud_server_default_ssh_keys
#### Default value
```YAML
hcloud_server_default_ssh_keys: []
```
### hcloud_server_networks
#### Default value
```YAML
hcloud_server_networks: []
```
#### Example usage
```YAML
hcloud_server_networks:
- name: network-1
ip: 10.0.0.1
state: present
```
### hcloud_server_rdns
#### Default value
```YAML
hcloud_server_rdns: []
```
#### Example usage
```YAML
hcloud_server_rdns:
- addr: 1.2.3.4
ptr: example.com
state: present
```
### hcloud_server_volumes
#### Default value
```YAML
hcloud_server_volumes: []
```
#### Example usage
```YAML
hcloud_server_volumes:
- name: my-volume
size: 10
state: present
```
## Dependencies
None.

View File

@ -1,25 +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: hcloud_server
# @meta description: >
# [![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.hcloud_server)
# [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.hcloud_server?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.hcloud_server)
# [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.hcloud_server/src/branch/main/LICENSE)
#
# Manage Hetzner Cloud server instances
# @end
description: Manage Hetzner Cloud server instances
license: MIT
min_ansible_version: 2.10
platforms:
- name: EL
versions:
- 7
galaxy_tags: []
dependencies: []
collections:
- community.general

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,5 +0,0 @@
---
- include_tasks: setup.yml
when:
- hcloud_server is defined
- hcloud_server.name is defined

View File

@ -1,72 +0,0 @@
---
- name: Provisioning VM '{{ hcloud_server.name }}'
hcloud_server:
name: "{{ hcloud_server.name }}"
server_type: "{{ hcloud_server.type | default('cx11') }}"
ssh_keys: "{{ hcloud_server.ssh_keys | default(hcloud_server_default_ssh_keys) }}"
image: "{{ hcloud_server.image | default(hcloud_server_default_image) }}"
location: "{{ hcloud_server.location | default(hcloud_server_default_location) }}"
backups: "{{ hcloud_server.backups | default(hcloud_server_default_backup) }}"
delete_protection: "{{ hcloud_server.protection | default(hcloud_server_default_protection) }}"
rebuild_protection: "{{ hcloud_server.protection | default(hcloud_server_default_protection) }}"
labels: "{{ hcloud_server.labels | default({}) }}"
api_token: "{{ hcloud_server.api_token | default(hcloud_server_default_api_token | default(omit)) }}"
state: present
changed_when: False
register: __hcloud_server
async: 7200
poll: 0
delegate_to: localhost
- name: Wait for instance creation to complete
async_status:
jid: "{{ __hcloud_server.ansible_job_id }}"
register: __hcloud_job
until: __hcloud_job.finished
retries: 300
delegate_to: localhost
- name: Populate instance config
set_fact:
hcloud_instance:
{
"instance": "{{ __hcloud_job.hcloud_server.name }}",
"ipv4": "{{ __hcloud_job.hcloud_server.ipv4_address }}",
"ipv6": "{{ __hcloud_job.hcloud_server.ipv6 }}",
}
delegate_to: localhost
- name: Attach server to local networks
hcloud_server_network:
network: "{{ item.name }}"
server: "{{ hcloud_server.name }}"
ip: "{{ item.ip }}"
state: "{{ item.state | default('present') }}"
loop: "{{ hcloud_server_networks }}"
loop_control:
label: "{{ hcloud_server.name }}:{{ item.name }}"
delegate_to: localhost
- name: Create volumes
hcloud_volume:
name: "{{ item.name }}"
server: "{{ hcloud_server.name }}"
size: "{{ item.size | default(10) }}"
api_token: "{{ hcloud_server.api_token | default(hcloud_server_default_api_token | default(omit)) }}"
state: "{{ item.state | default('present') }}"
loop: "{{ hcloud_server_volumes }}"
loop_control:
label: "{{ hcloud_server.name }}:{{ item.name }}"
delegate_to: localhost
- name: Create reverse DNS entries
hcloud_rdns:
server: "{{ hcloud_server.name }}"
ip_address: "{{ item.addr }}"
dns_ptr: "{{ item.ptr }}"
api_token: "{{ hcloud_server.api_token | default(hcloud_server_default_api_token | default(omit)) }}"
state: "{{ item.state | default('present') }}"
loop: "{{ hcloud_server_rdns }}"
loop_control:
label: "{{ hcloud_server.name }}:{{ item.ptr }}"
delegate_to: localhost