commit
905a0bb291
22 changed files with 371 additions and 0 deletions
@ -0,0 +1,7 @@ |
||||
*.retry |
||||
*/__pycache__ |
||||
*.pyc |
||||
.cache |
||||
.venv |
||||
.env.yml |
||||
docker-compose.yml |
@ -0,0 +1,29 @@ |
||||
--- |
||||
language: python |
||||
python: "2.7" |
||||
|
||||
# Use the new container infrastructure |
||||
sudo: false |
||||
|
||||
# Install ansible |
||||
addons: |
||||
apt: |
||||
packages: |
||||
- python-pip |
||||
|
||||
install: |
||||
# Install ansible |
||||
- pip install ansible |
||||
|
||||
# Check ansible version |
||||
- ansible --version |
||||
|
||||
# Create ansible.cfg with correct roles_path |
||||
- printf '[defaults]\nroles_path=../' >ansible.cfg |
||||
|
||||
script: |
||||
# Basic role syntax check |
||||
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check |
||||
|
||||
notifications: |
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ |
@ -0,0 +1,33 @@ |
||||
--- |
||||
# Based on ansible-lint config |
||||
extends: default |
||||
|
||||
rules: |
||||
braces: |
||||
max-spaces-inside: 1 |
||||
level: error |
||||
brackets: |
||||
max-spaces-inside: 1 |
||||
level: error |
||||
colons: |
||||
max-spaces-after: -1 |
||||
level: error |
||||
commas: |
||||
max-spaces-after: -1 |
||||
level: error |
||||
comments: disable |
||||
comments-indentation: disable |
||||
document-start: disable |
||||
empty-lines: |
||||
max: 3 |
||||
level: error |
||||
hyphens: |
||||
level: error |
||||
indentation: disable |
||||
key-duplicates: enable |
||||
line-length: disable |
||||
new-line-at-end-of-file: disable |
||||
new-lines: |
||||
type: unix |
||||
trailing-spaces: disable |
||||
truthy: disable |
@ -0,0 +1,20 @@ |
||||
The MIT License (MIT) |
||||
|
||||
Copyright (c) 2022 Laur Ivan |
||||
|
||||
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 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. |
@ -0,0 +1,38 @@ |
||||
Role Name |
||||
========= |
||||
|
||||
A brief description of the role goes here. |
||||
|
||||
Requirements |
||||
------------ |
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. |
||||
|
||||
Role Variables |
||||
-------------- |
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. |
||||
|
||||
Dependencies |
||||
------------ |
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. |
||||
|
||||
Example Playbook |
||||
---------------- |
||||
|
||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: |
||||
|
||||
- hosts: servers |
||||
roles: |
||||
- { role: username.rolename, x: 42 } |
||||
|
||||
License |
||||
------- |
||||
|
||||
BSD |
||||
|
||||
Author Information |
||||
------------------ |
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed). |
@ -0,0 +1,2 @@ |
||||
--- |
||||
# defaults file for arrs |
@ -0,0 +1,2 @@ |
||||
--- |
||||
# handlers file for arrs |
@ -0,0 +1,37 @@ |
||||
galaxy_info: |
||||
author: Laur Ivan |
||||
namespace: laurivan |
||||
role_name: arrs |
||||
description: Sonarr, Lidarr, Deluge and proxy via Docker |
||||
license: MIT |
||||
|
||||
min_ansible_version: "2.4" |
||||
min_ansible_container_version: "2.4" |
||||
|
||||
platforms: |
||||
- name: Debian |
||||
versions: |
||||
- buster |
||||
- bullseye |
||||
- name: Ubuntu |
||||
versions: |
||||
- bionic |
||||
- focal |
||||
- jammy |
||||
- name: Alpine |
||||
version: |
||||
- all |
||||
- name: ArchLinux |
||||
versions: |
||||
- all |
||||
|
||||
galaxy_tags: |
||||
- sonarr |
||||
- lidarr |
||||
- deluge |
||||
- proxy |
||||
- media |
||||
- grabber |
||||
- docker |
||||
|
||||
dependencies: [] |
@ -0,0 +1,15 @@ |
||||
*********************************** |
||||
Delegated driver installation guide |
||||
*********************************** |
||||
|
||||
Requirements |
||||
============ |
||||
|
||||
This driver is delegated to the developer. Up to the developer to implement |
||||
requirements. |
||||
|
||||
Install |
||||
======= |
||||
|
||||
This driver is delegated to the developer. Up to the developer to implement |
||||
requirements. |
@ -0,0 +1,23 @@ |
||||
--- |
||||
- name: Clean up |
||||
hosts: all |
||||
gather_facts: true |
||||
tasks: |
||||
- name: Check if the docker-compose file exists. |
||||
ansible.builtin.stat: |
||||
path: "~/plausible/docker-compose.yml" |
||||
register: docker_compose_file |
||||
|
||||
- name: Remove docker-compose. |
||||
community.docker.docker_compose: |
||||
project_src: ~/arrs/ |
||||
build: false |
||||
state: absent |
||||
when: docker_compose_file.stat.exists |
||||
become: false |
||||
|
||||
- name: Remove the docker-compose file |
||||
ansible.builtin.file: |
||||
path: "~/arrs/docker-compose.yml" |
||||
state: absent |
||||
when: docker_compose_file.stat.exists |
@ -0,0 +1,12 @@ |
||||
--- |
||||
- name: Converge |
||||
hosts: all |
||||
# gather_facts: false |
||||
pre_tasks: |
||||
- name: "Include necessary variables" |
||||
ansible.builtin.include_vars: |
||||
file: "../../.env.yml" |
||||
|
||||
roles: |
||||
- role: laurivan.arrs |
||||
|
@ -0,0 +1,35 @@ |
||||
--- |
||||
- name: Create |
||||
hosts: localhost |
||||
connection: local |
||||
gather_facts: false |
||||
no_log: "{{ molecule_no_log }}" |
||||
tasks: |
||||
|
||||
# TODO: Developer must implement and populate 'server' variable |
||||
|
||||
- when: server.changed | default(false) | bool |
||||
block: |
||||
- name: Populate instance config dict |
||||
ansible.builtin.set_fact: |
||||
instance_conf_dict: { |
||||
'instance': "{{ }}", |
||||
'address': "{{ }}", |
||||
'user': "{{ }}", |
||||
'port': "{{ }}", |
||||
'identity_file': "{{ }}", } |
||||
with_items: "{{ server.results }}" |
||||
register: instance_config_dict |
||||
|
||||
- name: Convert instance config dict to a list |
||||
ansible.builtin.set_fact: |
||||
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" |
||||
|
||||
- name: Dump instance config |
||||
ansible.builtin.copy: |
||||
content: | |
||||
# Molecule managed |
||||
|
||||
{{ instance_conf | to_json | from_json | to_yaml }} |
||||
dest: "{{ molecule_instance_config }}" |
||||
mode: 0600 |
@ -0,0 +1,28 @@ |
||||
--- |
||||
- name: Destroy |
||||
hosts: localhost |
||||
connection: local |
||||
gather_facts: false |
||||
no_log: "{{ molecule_no_log }}" |
||||
tasks: |
||||
# Developer must implement. |
||||
- name: Remove the docker image |
||||
community.docker.docker_container: |
||||
name: instance-arrs |
||||
state: absent |
||||
|
||||
# Mandatory configuration for Molecule to function. |
||||
|
||||
- name: Populate instance config |
||||
ansible.builtin.set_fact: |
||||
instance_conf: {} |
||||
|
||||
- name: Dump instance config |
||||
ansible.builtin.copy: |
||||
content: | |
||||
# Molecule managed |
||||
|
||||
{{ instance_conf | to_json | from_json | to_yaml }} |
||||
dest: "{{ molecule_instance_config }}" |
||||
mode: 0600 |
||||
when: server.changed | default(false) | bool |
@ -0,0 +1,30 @@ |
||||
--- |
||||
role_name_check: 1 |
||||
dependency: |
||||
name: galaxy |
||||
options: |
||||
ignore-certs: true |
||||
ignore-errors: true |
||||
role-file: molecule/requirements.yml |
||||
requirements-file: molecule/requirements.yml |
||||
driver: |
||||
name: docker |
||||
platforms: |
||||
- name: instance-arrs |
||||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest" |
||||
command: ${MOLECULE_DOCKER_COMMAND:-""} |
||||
volumes: |
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro |
||||
- /var/run/docker.sock:/tmp/docker_mounted.sock |
||||
privileged: true |
||||
pre_build_image: true |
||||
provisioner: |
||||
name: ansible |
||||
playbooks: |
||||
converge: ${MOLECULE_PLAYBOOK:-converge.yml} |
||||
verifier: |
||||
name: ansible |
||||
lint: | |
||||
set -e |
||||
yamllint . |
||||
ansible-lint . |
@ -0,0 +1,35 @@ |
||||
--- |
||||
- name: Setup the test machine |
||||
hosts: instance-arrs |
||||
tasks: |
||||
- name: Check if /var/run/docker.sock already exists |
||||
ansible.builtin.stat: |
||||
path: "/var/run/docker.sock" |
||||
register: docker_sock_stat |
||||
|
||||
- name: Create docker.sock |
||||
raw: touch /var/run/docker.sock |
||||
become: true |
||||
changed_when: false |
||||
when: not docker_sock_stat.stat.exists |
||||
|
||||
- name: Move docker.sock from tmp |
||||
raw: mount --move /tmp/docker_mounted.sock /var/run/docker.sock |
||||
become: true |
||||
changed_when: false |
||||
when: not docker_sock_stat.stat.exists |
||||
|
||||
- name: Update apt cache. |
||||
apt: update_cache=yes cache_valid_time=600 |
||||
when: ansible_os_family == 'Debian' |
||||
- name: Install python requests |
||||
pip: |
||||
name: |
||||
- requests |
||||
- docker |
||||
- docker-compose |
||||
- name: Install docker |
||||
vars: |
||||
docker_service_manage: false |
||||
include_role: |
||||
name: geerlingguy.docker |
@ -0,0 +1,10 @@ |
||||
--- |
||||
# This is an example playbook to execute Ansible tests. |
||||
|
||||
- name: Verify |
||||
hosts: all |
||||
gather_facts: false |
||||
tasks: |
||||
- name: Example assertion |
||||
ansible.builtin.assert: |
||||
that: true |
@ -0,0 +1,4 @@ |
||||
--- |
||||
roles: |
||||
- geerlingguy.docker |
||||
collections: [] |
@ -0,0 +1,2 @@ |
||||
--- |
||||
# tasks file for arrs |
@ -0,0 +1,2 @@ |
||||
localhost |
||||
|
@ -0,0 +1,5 @@ |
||||
--- |
||||
- hosts: localhost |
||||
remote_user: root |
||||
roles: |
||||
- arrs |
@ -0,0 +1,2 @@ |
||||
--- |
||||
# vars file for arrs |
Loading…
Reference in new issue