This commit is contained in:
parent
fb1acab732
commit
bacc486091
109
.drone.jsonnet
Normal file
109
.drone.jsonnet
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
local AnsibleVersions(version="latest", package="ansible") = {
|
||||||
|
name: "ansible-" + version,
|
||||||
|
image: "python:3.7",
|
||||||
|
pull: "always",
|
||||||
|
environment: {
|
||||||
|
PY_COLORS: 1
|
||||||
|
},
|
||||||
|
commands: [
|
||||||
|
"pip install " + package + " ansible-later~=0.2.0 -qq",
|
||||||
|
"git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy",
|
||||||
|
"ansible-later -c ~/policy/config.yml"
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
"clone",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
local PipelineLinting = {
|
||||||
|
kind: "pipeline",
|
||||||
|
name: "linting",
|
||||||
|
platform: {
|
||||||
|
os: "linux",
|
||||||
|
arch: "amd64",
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
AnsibleVersions(version="latest", package="ansible"),
|
||||||
|
AnsibleVersions(version="master", package="git+https://github.com/ansible/ansible.git@devel"),
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
local PipelineDeployment = {
|
||||||
|
kind: "pipeline",
|
||||||
|
name: "deployment",
|
||||||
|
platform: {
|
||||||
|
os: "linux",
|
||||||
|
arch: "amd64",
|
||||||
|
},
|
||||||
|
workspace: {
|
||||||
|
base: "/drone/src",
|
||||||
|
path: "xoxys.jellyfin"
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: "molecule",
|
||||||
|
image: "xoxys/molecule:ec2-linux-amd64",
|
||||||
|
pull: "always",
|
||||||
|
environment: {
|
||||||
|
ANSIBLE_ROLES_PATH: "/drone/src",
|
||||||
|
AWS_ACCESS_KEY_ID: { "from_secret": "aws_access_key_id" },
|
||||||
|
AWS_SECRET_ACCESS_KEY: { "from_secret": "aws_secret_access_key" },
|
||||||
|
AWS_REGION: "eu-central-1",
|
||||||
|
MOLECULE_CUSTOM_MODULES_REPO: "https://gitea.rknet.org/ansible/custom_modules",
|
||||||
|
MOLECULE_CUSTOM_FILTERS_REPO: "https://gitea.rknet.org/ansible/custom_filters",
|
||||||
|
PY_COLORS: 1
|
||||||
|
},
|
||||||
|
commands: [
|
||||||
|
"/bin/bash /docker-entrypoint.sh",
|
||||||
|
"molecule test --scenario-name ec2-centos-7",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
"linting",
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ["refs/heads/master", "refs/tags/**"],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
local PipelineNotifications = {
|
||||||
|
kind: "pipeline",
|
||||||
|
name: "notifications",
|
||||||
|
platform: {
|
||||||
|
os: "linux",
|
||||||
|
arch: "amd64",
|
||||||
|
},
|
||||||
|
clone: {
|
||||||
|
disable: true,
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: "matrix",
|
||||||
|
image: "plugins/matrix",
|
||||||
|
settings: {
|
||||||
|
homeserver: "https://matrix.rknet.org",
|
||||||
|
roomid: "MtidqQXWWAtQcByBhH:rknet.org",
|
||||||
|
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}",
|
||||||
|
username: { "from_secret": "matrix_username" },
|
||||||
|
password: { "from_secret": "matrix_password" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
"deployment",
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
status: [ "success", "failure" ],
|
||||||
|
ref: ["refs/heads/master", "refs/tags/**"],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
[
|
||||||
|
PipelineLinting,
|
||||||
|
PipelineDeployment,
|
||||||
|
PipelineNotifications,
|
||||||
|
]
|
144
.drone.yml
144
.drone.yml
@ -1,40 +1,116 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: default
|
name: linting
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: ansible-latest
|
- name: ansible-latest
|
||||||
image: python:2.7
|
pull: always
|
||||||
pull: always
|
image: python:3.7
|
||||||
commands:
|
commands:
|
||||||
- pip install ansible ansible-later -q
|
- pip install ansible ansible-later~=0.2.0 -qq
|
||||||
- git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy
|
- git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy
|
||||||
- git ls-files *[^LICENSE,.md] | xargs ansible-later -c ~/policy/config.ini
|
- ansible-later -c ~/policy/config.yml
|
||||||
depends_on: [ clone ]
|
environment:
|
||||||
|
PY_COLORS: 1
|
||||||
|
depends_on:
|
||||||
|
- clone
|
||||||
|
|
||||||
- name: ansible-master
|
- name: ansible-master
|
||||||
image: python:2.7
|
pull: always
|
||||||
pull: always
|
image: python:3.7
|
||||||
commands:
|
commands:
|
||||||
- pip install ansible ansible-later -q
|
- "pip install git+https://github.com/ansible/ansible.git@devel ansible-later~=0.2.0 -qq"
|
||||||
- git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy
|
- git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy
|
||||||
- git ls-files *[^LICENSE,.md] | xargs ansible-later -c ~/policy/config.ini
|
- ansible-later -c ~/policy/config.yml
|
||||||
depends_on: [ clone ]
|
environment:
|
||||||
|
PY_COLORS: 1
|
||||||
|
depends_on:
|
||||||
|
- clone
|
||||||
|
|
||||||
- name: notify
|
trigger:
|
||||||
image: plugins/matrix
|
ref:
|
||||||
settings:
|
- refs/heads/master
|
||||||
homeserver: https://matrix.rknet.org
|
- "refs/tags/**"
|
||||||
roomid: MtidqQXWWAtQcByBhH:rknet.org
|
- "refs/pull/**"
|
||||||
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}"
|
|
||||||
username:
|
---
|
||||||
from_secret: matrix_username
|
kind: pipeline
|
||||||
password:
|
name: deployment
|
||||||
from_secret: matrix_password
|
|
||||||
depends_on:
|
platform:
|
||||||
- ansible-latest
|
os: linux
|
||||||
- ansible-master
|
arch: amd64
|
||||||
when:
|
|
||||||
status:
|
workspace:
|
||||||
- success
|
base: /drone/src
|
||||||
- failure
|
path: xoxys.jellyfin
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: molecule
|
||||||
|
pull: always
|
||||||
|
image: xoxys/molecule:ec2-linux-amd64
|
||||||
|
commands:
|
||||||
|
- /bin/bash /docker-entrypoint.sh
|
||||||
|
- molecule test --scenario-name ec2-centos-7
|
||||||
|
environment:
|
||||||
|
ANSIBLE_ROLES_PATH: /drone/src
|
||||||
|
AWS_ACCESS_KEY_ID:
|
||||||
|
from_secret: aws_access_key_id
|
||||||
|
AWS_REGION: eu-central-1
|
||||||
|
AWS_SECRET_ACCESS_KEY:
|
||||||
|
from_secret: aws_secret_access_key
|
||||||
|
MOLECULE_CUSTOM_FILTERS_REPO: https://gitea.rknet.org/ansible/custom_filters
|
||||||
|
MOLECULE_CUSTOM_MODULES_REPO: https://gitea.rknet.org/ansible/custom_modules
|
||||||
|
PY_COLORS: 1
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/master
|
||||||
|
- "refs/tags/**"
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- linting
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: notifications
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
clone:
|
||||||
|
disable: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: matrix
|
||||||
|
image: plugins/matrix
|
||||||
|
settings:
|
||||||
|
homeserver: https://matrix.rknet.org
|
||||||
|
password:
|
||||||
|
from_secret: matrix_password
|
||||||
|
roomid: MtidqQXWWAtQcByBhH:rknet.org
|
||||||
|
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}"
|
||||||
|
username:
|
||||||
|
from_secret: matrix_username
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/master
|
||||||
|
- "refs/tags/**"
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
- failure
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- deployment
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: signature
|
||||||
|
hmac: e25323c42ef77596b421d0fee5f148f6ddeb0e74cd426d65bb1a7c6714103187
|
||||||
|
|
||||||
|
...
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
jellyfin_version: 10.1
|
jellyfin_version: 10.3.7
|
||||||
jellyfin_user: jellyfin
|
jellyfin_user: jellyfin
|
||||||
jellyfin_user_home: "/home/{{ jellyfin_user }}"
|
jellyfin_user_home: "/home/{{ jellyfin_user }}"
|
||||||
# jellyfin_uid: # defaults to not set
|
# jellyfin_uid: # defaults to not set
|
||||||
@ -22,14 +22,6 @@ jellyfin_conf_dir: "{{ jellyfin_base_dir }}/config"
|
|||||||
jellyfin_data_dir: "{{ jellyfin_base_dir }}/data"
|
jellyfin_data_dir: "{{ jellyfin_base_dir }}/data"
|
||||||
jellyfin_log_dir: "{{ jellyfin_base_dir }}/log"
|
jellyfin_log_dir: "{{ jellyfin_base_dir }}/log"
|
||||||
|
|
||||||
jellyfin_dependencies:
|
|
||||||
- lttng-ust
|
|
||||||
- libcurl
|
|
||||||
- openssl-libs
|
|
||||||
- krb5-libs
|
|
||||||
- libicu
|
|
||||||
- zlib
|
|
||||||
|
|
||||||
jellyfin_logrotate_enabled: False
|
jellyfin_logrotate_enabled: False
|
||||||
jellyfin_logrotate_config:
|
jellyfin_logrotate_config:
|
||||||
- log: "{{ jellyfin_log_dir }}/jellyfin.log"
|
- log: "{{ jellyfin_log_dir }}/jellyfin.log"
|
||||||
@ -45,7 +37,6 @@ jellyfin_logrotate_config:
|
|||||||
jellyfin_log_level_console: Fatal
|
jellyfin_log_level_console: Fatal
|
||||||
jellyfin_log_level_file: Information
|
jellyfin_log_level_file: Information
|
||||||
|
|
||||||
jellyfin_base_url: https://mystream.example.com
|
|
||||||
# DONT CHANGE IT!
|
# DONT CHANGE IT!
|
||||||
# Changing the bind ports is currently not supported
|
# Changing the bind ports is currently not supported
|
||||||
jellyfin_http_bind_port: 8096
|
jellyfin_http_bind_port: 8096
|
||||||
@ -62,17 +53,3 @@ jellyfin_open_ports:
|
|||||||
rules: |
|
rules: |
|
||||||
-A OUTPUT -m state --state NEW -p udp --destination 239.255.255.250 --dport 1900 -j ACCEPT
|
-A OUTPUT -m state --state NEW -p udp --destination 239.255.255.250 --dport 1900 -j ACCEPT
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
jellyfin_tls_cert_source: mycert.pem
|
|
||||||
jellyfin_tls_key_source: mykey.pem
|
|
||||||
|
|
||||||
jellyfin_nginx_vhost_enabled: False
|
|
||||||
jellyfin_nginx_server: localhost
|
|
||||||
jellyfin_nginx_vhost_dir: /etc/nginx/sites-available
|
|
||||||
jellyfin_nginx_vhost_symlink: /etc/nginx/sites-enabled
|
|
||||||
jellyfin_nginx_iptables_enabled: False
|
|
||||||
jellyfin_nginx_tls_enabled: False
|
|
||||||
jellyfin_nginx_tls_cert_file: jellyfin-cert.pem
|
|
||||||
jellyfin_nginx_tls_key_file: jellyfin-key.pem
|
|
||||||
jellyfin_nginx_proxy_port: "{{ jellyfin_http_bind_port }}"
|
|
||||||
jellyfin_nginx_proxy_ip: "{{ ansible_default_ipv4.address }}"
|
|
||||||
|
22
molecule/default/INSTALL.rst
Normal file
22
molecule/default/INSTALL.rst
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
*******
|
||||||
|
Amazon Web Services driver installation guide
|
||||||
|
*******
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
============
|
||||||
|
|
||||||
|
* An AWS credentials rc file
|
||||||
|
|
||||||
|
Install
|
||||||
|
=======
|
||||||
|
|
||||||
|
Please refer to the `Virtual environment`_ documentation for installation best
|
||||||
|
practices. If not using a virtual environment, please consider passing the
|
||||||
|
widely recommended `'--user' flag`_ when invoking ``pip``.
|
||||||
|
|
||||||
|
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
|
||||||
|
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ pip install 'molecule[ec2]'
|
125
molecule/default/create.yml
Normal file
125
molecule/default/create.yml
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
---
|
||||||
|
- name: Create
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
gather_facts: false
|
||||||
|
no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
|
||||||
|
vars:
|
||||||
|
ssh_user: ubuntu
|
||||||
|
ssh_port: 22
|
||||||
|
|
||||||
|
security_group_name: molecule
|
||||||
|
security_group_description: Security group for testing Molecule
|
||||||
|
security_group_rules:
|
||||||
|
- proto: tcp
|
||||||
|
from_port: "{{ ssh_port }}"
|
||||||
|
to_port: "{{ ssh_port }}"
|
||||||
|
cidr_ip: '0.0.0.0/0'
|
||||||
|
- proto: icmp
|
||||||
|
from_port: 8
|
||||||
|
to_port: -1
|
||||||
|
cidr_ip: '0.0.0.0/0'
|
||||||
|
security_group_rules_egress:
|
||||||
|
- proto: -1
|
||||||
|
from_port: 0
|
||||||
|
to_port: 0
|
||||||
|
cidr_ip: '0.0.0.0/0'
|
||||||
|
|
||||||
|
keypair_name: molecule_key
|
||||||
|
keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
|
||||||
|
tasks:
|
||||||
|
- name: Create security group
|
||||||
|
ec2_group:
|
||||||
|
name: "{{ security_group_name }}"
|
||||||
|
description: "{{ security_group_name }}"
|
||||||
|
rules: "{{ security_group_rules }}"
|
||||||
|
rules_egress: "{{ security_group_rules_egress }}"
|
||||||
|
|
||||||
|
- name: Test for presence of local keypair
|
||||||
|
stat:
|
||||||
|
path: "{{ keypair_path }}"
|
||||||
|
register: keypair_local
|
||||||
|
|
||||||
|
- name: Delete remote keypair
|
||||||
|
ec2_key:
|
||||||
|
name: "{{ keypair_name }}"
|
||||||
|
state: absent
|
||||||
|
when: not keypair_local.stat.exists
|
||||||
|
|
||||||
|
- name: Create keypair
|
||||||
|
ec2_key:
|
||||||
|
name: "{{ keypair_name }}"
|
||||||
|
register: keypair
|
||||||
|
|
||||||
|
- name: Persist the keypair
|
||||||
|
copy:
|
||||||
|
dest: "{{ keypair_path }}"
|
||||||
|
content: "{{ keypair.key.private_key }}"
|
||||||
|
mode: 0600
|
||||||
|
when: keypair.changed
|
||||||
|
|
||||||
|
- name: Create molecule instance(s)
|
||||||
|
ec2:
|
||||||
|
key_name: "{{ keypair_name }}"
|
||||||
|
image: "{{ item.image }}"
|
||||||
|
instance_type: "{{ item.instance_type }}"
|
||||||
|
vpc_subnet_id: "{{ item.vpc_subnet_id }}"
|
||||||
|
group: "{{ security_group_name }}"
|
||||||
|
instance_tags:
|
||||||
|
instance: "{{ item.name }}"
|
||||||
|
wait: true
|
||||||
|
assign_public_ip: true
|
||||||
|
exact_count: 1
|
||||||
|
count_tag:
|
||||||
|
instance: "{{ item.name }}"
|
||||||
|
register: server
|
||||||
|
with_items: "{{ molecule_yml.platforms }}"
|
||||||
|
async: 7200
|
||||||
|
poll: 0
|
||||||
|
|
||||||
|
- name: Wait for instance(s) creation to complete
|
||||||
|
async_status:
|
||||||
|
jid: "{{ item.ansible_job_id }}"
|
||||||
|
register: ec2_jobs
|
||||||
|
until: ec2_jobs.finished
|
||||||
|
retries: 300
|
||||||
|
with_items: "{{ server.results }}"
|
||||||
|
|
||||||
|
# Mandatory configuration for Molecule to function.
|
||||||
|
|
||||||
|
- name: Populate instance config dict
|
||||||
|
set_fact:
|
||||||
|
instance_conf_dict: {
|
||||||
|
'instance': "{{ item.instances[0].tags.instance }}",
|
||||||
|
'address': "{{ item.instances[0].public_ip }}",
|
||||||
|
'user': "{{ ssh_user }}",
|
||||||
|
'port': "{{ ssh_port }}",
|
||||||
|
'identity_file': "{{ keypair_path }}",
|
||||||
|
'instance_ids': "{{ item.instance_ids }}", }
|
||||||
|
with_items: "{{ ec2_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: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
|
||||||
|
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
|
||||||
|
timeout: 320
|
||||||
|
with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
||||||
|
|
||||||
|
- name: Wait for boot process to finish
|
||||||
|
pause:
|
||||||
|
minutes: 2
|
47
molecule/default/destroy.yml
Normal file
47
molecule/default/destroy.yml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
- name: Destroy
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
gather_facts: false
|
||||||
|
no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- name: Populate instance config
|
||||||
|
set_fact:
|
||||||
|
instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
||||||
|
skip_instances: false
|
||||||
|
rescue:
|
||||||
|
- name: Populate instance config when file missing
|
||||||
|
set_fact:
|
||||||
|
instance_conf: {}
|
||||||
|
skip_instances: true
|
||||||
|
|
||||||
|
- name: Destroy molecule instance(s)
|
||||||
|
ec2:
|
||||||
|
state: absent
|
||||||
|
instance_ids: "{{ item.instance_ids }}"
|
||||||
|
register: server
|
||||||
|
with_items: "{{ instance_conf }}"
|
||||||
|
when: not skip_instances
|
||||||
|
async: 7200
|
||||||
|
poll: 0
|
||||||
|
|
||||||
|
- name: Wait for instance(s) deletion to complete
|
||||||
|
async_status:
|
||||||
|
jid: "{{ item.ansible_job_id }}"
|
||||||
|
register: ec2_jobs
|
||||||
|
until: ec2_jobs.finished
|
||||||
|
retries: 300
|
||||||
|
with_items: "{{ server.results }}"
|
||||||
|
|
||||||
|
# Mandatory configuration for Molecule to function.
|
||||||
|
|
||||||
|
- name: Populate instance config
|
||||||
|
set_fact:
|
||||||
|
instance_conf: {}
|
||||||
|
|
||||||
|
- name: Dump instance config
|
||||||
|
copy:
|
||||||
|
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
|
||||||
|
dest: "{{ molecule_instance_config }}"
|
||||||
|
when: server.changed | bool
|
20
molecule/default/molecule.yml
Normal file
20
molecule/default/molecule.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: ec2
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
platforms:
|
||||||
|
- name: instance
|
||||||
|
image: ami-a5b196c0
|
||||||
|
instance_type: t2.micro
|
||||||
|
vpc_subnet_id: subnet-6456fd1f
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
5
molecule/default/playbook.yml
Normal file
5
molecule/default/playbook.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- role: xoxys.jellyfin
|
9
molecule/default/prepare.yml
Normal file
9
molecule/default/prepare.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Install python for Ansible
|
||||||
|
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-zipstream)
|
||||||
|
become: true
|
||||||
|
changed_when: false
|
14
molecule/default/tests/test_default.py
Normal file
14
molecule/default/tests/test_default.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||||
|
|
||||||
|
|
||||||
|
def test_hosts_file(host):
|
||||||
|
f = host.file('/etc/hosts')
|
||||||
|
|
||||||
|
assert f.exists
|
||||||
|
assert f.user == 'root'
|
||||||
|
assert f.group == 'root'
|
22
molecule/ec2-centos-7/INSTALL.rst
Normal file
22
molecule/ec2-centos-7/INSTALL.rst
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
*******
|
||||||
|
Amazon Web Services driver installation guide
|
||||||
|
*******
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
============
|
||||||
|
|
||||||
|
* An AWS credentials rc file
|
||||||
|
|
||||||
|
Install
|
||||||
|
=======
|
||||||
|
|
||||||
|
Please refer to the `Virtual environment`_ documentation for installation best
|
||||||
|
practices. If not using a virtual environment, please consider passing the
|
||||||
|
widely recommended `'--user' flag`_ when invoking ``pip``.
|
||||||
|
|
||||||
|
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
|
||||||
|
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ pip install 'molecule[ec2]'
|
124
molecule/ec2-centos-7/create.yml
Normal file
124
molecule/ec2-centos-7/create.yml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
---
|
||||||
|
- name: Create
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
gather_facts: false
|
||||||
|
no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
|
||||||
|
vars:
|
||||||
|
ssh_user: centos
|
||||||
|
ssh_port: 22
|
||||||
|
|
||||||
|
security_group_name: molecule
|
||||||
|
security_group_description: Security group for testing Molecule
|
||||||
|
security_group_rules:
|
||||||
|
- proto: tcp
|
||||||
|
from_port: "{{ ssh_port }}"
|
||||||
|
to_port: "{{ ssh_port }}"
|
||||||
|
cidr_ip: '0.0.0.0/0'
|
||||||
|
- proto: icmp
|
||||||
|
from_port: 8
|
||||||
|
to_port: -1
|
||||||
|
cidr_ip: '0.0.0.0/0'
|
||||||
|
security_group_rules_egress:
|
||||||
|
- proto: -1
|
||||||
|
from_port: 0
|
||||||
|
to_port: 0
|
||||||
|
cidr_ip: '0.0.0.0/0'
|
||||||
|
|
||||||
|
keypair_name: molecule_key_jellyfin
|
||||||
|
keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
|
||||||
|
tasks:
|
||||||
|
- name: Create security group
|
||||||
|
ec2_group:
|
||||||
|
name: "{{ security_group_name }}"
|
||||||
|
description: "{{ security_group_name }}"
|
||||||
|
rules: "{{ security_group_rules }}"
|
||||||
|
rules_egress: "{{ security_group_rules_egress }}"
|
||||||
|
|
||||||
|
- name: Delete remote keypair
|
||||||
|
ec2_key:
|
||||||
|
name: "{{ keypair_name }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Create keypair
|
||||||
|
ec2_key:
|
||||||
|
name: "{{ keypair_name }}"
|
||||||
|
register: keypair
|
||||||
|
|
||||||
|
- name: Persist the keypair
|
||||||
|
copy:
|
||||||
|
dest: "{{ keypair_path }}"
|
||||||
|
content: "{{ keypair.key.private_key }}"
|
||||||
|
mode: 0600
|
||||||
|
when: keypair.changed
|
||||||
|
|
||||||
|
- name: Create molecule instance(s)
|
||||||
|
ec2:
|
||||||
|
key_name: "{{ keypair_name }}"
|
||||||
|
image: "{{ item.image }}"
|
||||||
|
instance_type: "{{ item.instance_type }}"
|
||||||
|
vpc_subnet_id: "{{ item.vpc_subnet_id }}"
|
||||||
|
group: "{{ security_group_name }}"
|
||||||
|
instance_tags:
|
||||||
|
instance: "{{ item.name }}"
|
||||||
|
wait: true
|
||||||
|
assign_public_ip: true
|
||||||
|
exact_count: 1
|
||||||
|
count_tag:
|
||||||
|
instance: "{{ item.name }}"
|
||||||
|
volumes:
|
||||||
|
- device_name: /dev/sda1
|
||||||
|
volume_type: gp2
|
||||||
|
volume_size: 8
|
||||||
|
delete_on_termination: yes
|
||||||
|
register: server
|
||||||
|
with_items: "{{ molecule_yml.platforms }}"
|
||||||
|
async: 7200
|
||||||
|
poll: 0
|
||||||
|
|
||||||
|
- name: Wait for instance(s) creation to complete
|
||||||
|
async_status:
|
||||||
|
jid: "{{ item.ansible_job_id }}"
|
||||||
|
register: ec2_jobs
|
||||||
|
until: ec2_jobs.finished
|
||||||
|
retries: 300
|
||||||
|
with_items: "{{ server.results }}"
|
||||||
|
|
||||||
|
# Mandatory configuration for Molecule to function.
|
||||||
|
|
||||||
|
- name: Populate instance config dict
|
||||||
|
set_fact:
|
||||||
|
instance_conf_dict: {
|
||||||
|
'instance': "{{ item.instances[0].tags.instance }}",
|
||||||
|
'address': "{{ item.instances[0].public_ip }}",
|
||||||
|
'user': "{{ ssh_user }}",
|
||||||
|
'port': "{{ ssh_port }}",
|
||||||
|
'identity_file': "{{ keypair_path }}",
|
||||||
|
'instance_ids': "{{ item.instance_ids }}", }
|
||||||
|
with_items: "{{ ec2_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: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
|
||||||
|
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
|
||||||
|
timeout: 320
|
||||||
|
with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
||||||
|
|
||||||
|
- name: Wait for boot process to finish
|
||||||
|
pause:
|
||||||
|
minutes: 2
|
47
molecule/ec2-centos-7/destroy.yml
Normal file
47
molecule/ec2-centos-7/destroy.yml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
- name: Destroy
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
gather_facts: false
|
||||||
|
no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- name: Populate instance config
|
||||||
|
set_fact:
|
||||||
|
instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
||||||
|
skip_instances: false
|
||||||
|
rescue:
|
||||||
|
- name: Populate instance config when file missing
|
||||||
|
set_fact:
|
||||||
|
instance_conf: {}
|
||||||
|
skip_instances: true
|
||||||
|
|
||||||
|
- name: Destroy molecule instance(s)
|
||||||
|
ec2:
|
||||||
|
state: absent
|
||||||
|
instance_ids: "{{ item.instance_ids }}"
|
||||||
|
register: server
|
||||||
|
with_items: "{{ instance_conf }}"
|
||||||
|
when: not skip_instances
|
||||||
|
async: 7200
|
||||||
|
poll: 0
|
||||||
|
|
||||||
|
- name: Wait for instance(s) deletion to complete
|
||||||
|
async_status:
|
||||||
|
jid: "{{ item.ansible_job_id }}"
|
||||||
|
register: ec2_jobs
|
||||||
|
until: ec2_jobs.finished
|
||||||
|
retries: 300
|
||||||
|
with_items: "{{ server.results }}"
|
||||||
|
|
||||||
|
# Mandatory configuration for Molecule to function.
|
||||||
|
|
||||||
|
- name: Populate instance config
|
||||||
|
set_fact:
|
||||||
|
instance_conf: {}
|
||||||
|
|
||||||
|
- name: Dump instance config
|
||||||
|
copy:
|
||||||
|
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
|
||||||
|
dest: "{{ molecule_instance_config }}"
|
||||||
|
when: server.changed | bool
|
22
molecule/ec2-centos-7/molecule.yml
Normal file
22
molecule/ec2-centos-7/molecule.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: ec2
|
||||||
|
platforms:
|
||||||
|
- name: centos-7-jellyfin
|
||||||
|
image: ami-04cf43aca3e6f3de3
|
||||||
|
instance_type: t2.micro
|
||||||
|
vpc_subnet_id: subnet-9b6896f1
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
enabled: False
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
enabled: False
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
5
molecule/ec2-centos-7/playbook.yml
Normal file
5
molecule/ec2-centos-7/playbook.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- role: xoxys.jellyfin
|
9
molecule/ec2-centos-7/prepare.yml
Normal file
9
molecule/ec2-centos-7/prepare.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Install python for Ansible
|
||||||
|
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-zipstream)
|
||||||
|
become: true
|
||||||
|
changed_when: false
|
21
molecule/ec2-centos-7/tests/test_default.py
Normal file
21
molecule/ec2-centos-7/tests/test_default.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||||
|
|
||||||
|
|
||||||
|
def test_jellyfin_running_and_enabled(host):
|
||||||
|
jellyfin = host.service("jellyfin")
|
||||||
|
assert jellyfin.is_running
|
||||||
|
assert jellyfin.is_enabled
|
||||||
|
|
||||||
|
|
||||||
|
def test_jellyfin_socket(host):
|
||||||
|
# Verify the socket is listening for HTTP traffic
|
||||||
|
assert host.socket("tcp://0.0.0.0:8096").is_listening
|
||||||
|
assert host.socket("tcp://0.0.0.0:8920").is_listening
|
3
molecule/pytest.ini
Normal file
3
molecule/pytest.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[pytest]
|
||||||
|
filterwarnings =
|
||||||
|
ignore::DeprecationWarning
|
@ -18,7 +18,7 @@
|
|||||||
- block:
|
- block:
|
||||||
- name: Install portable binary
|
- name: Install portable binary
|
||||||
unarchive:
|
unarchive:
|
||||||
src: https://repo.jellyfin.org/releases/server/linux/jellyfin_{{ jellyfin_version }}.portable-linux-amd64.tar.gz
|
src: https://repo.jellyfin.org/releases/server/linux/jellyfin_{{ jellyfin_version }}.portable.tar.gz
|
||||||
dest: "{{ jellyfin_base_dir }}/{{ jellyfin_version }}"
|
dest: "{{ jellyfin_base_dir }}/{{ jellyfin_version }}"
|
||||||
extra_opts:
|
extra_opts:
|
||||||
- --strip-components=1
|
- --strip-components=1
|
||||||
|
@ -3,6 +3,4 @@
|
|||||||
- import_tasks: storage.yml
|
- import_tasks: storage.yml
|
||||||
when: jellyfin_lvm_enabled
|
when: jellyfin_lvm_enabled
|
||||||
- include_tasks: install.yml
|
- include_tasks: install.yml
|
||||||
- import_tasks: nginx.yml
|
|
||||||
when: jellyfin_nginx_vhost_enabled
|
|
||||||
- include_tasks: post_tasks.yml
|
- include_tasks: post_tasks.yml
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
---
|
|
||||||
- block:
|
|
||||||
- name: Copy certs and private key to nginx proxy
|
|
||||||
copy:
|
|
||||||
src: "{{ item.src }}"
|
|
||||||
dest: "{{ item.dest }}"
|
|
||||||
mode: "{{ item.mode }}"
|
|
||||||
loop:
|
|
||||||
- { src: "{{ jellyfin_tls_key_source }}", dest: '/etc/pki/tls/private/{{ jellyfin_nginx_tls_key_file }}', mode: '0600' }
|
|
||||||
- { src: "{{ jellyfin_tls_cert_source }}", dest: '/etc/pki/tls/certs/{{ jellyfin_nginx_tls_cert_file }}', mode: '0750' }
|
|
||||||
loop_control:
|
|
||||||
label: "{{ item.dest }}"
|
|
||||||
notify: __nginx_reload
|
|
||||||
delegate_to: "{{ jellyfin_nginx_server }}"
|
|
||||||
when: jellyfin_nginx_tls_enabled
|
|
||||||
become: True
|
|
||||||
become_user: root
|
|
||||||
tags: tls_renewal
|
|
||||||
|
|
||||||
- block:
|
|
||||||
- name: Add vhost configuration file
|
|
||||||
template:
|
|
||||||
src: nginx/vhost.j2
|
|
||||||
dest: "{{ jellyfin_nginx_vhost_dir }}/jellyfin"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0640
|
|
||||||
notify: __nginx_reload
|
|
||||||
|
|
||||||
- name: Enable jellyfin vhost
|
|
||||||
file:
|
|
||||||
src: "{{ jellyfin_nginx_vhost_dir }}/jellyfin"
|
|
||||||
dest: "{{ jellyfin_nginx_vhost_symlink }}/jellyfin"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
state: link
|
|
||||||
notify: __nginx_reload
|
|
||||||
when: jellyfin_nginx_vhost_symlink is defined
|
|
||||||
|
|
||||||
- name: Open ports in iptables
|
|
||||||
iptables_raw:
|
|
||||||
name: allow_jellyfin_nginx_proxy
|
|
||||||
state: present
|
|
||||||
rules: '-A OUTPUT -m state --state NEW -p tcp -d {{ jellyfin_nginx_proxy_ip }} --dport {{ jellyfin_nginx_proxy_port }} -j ACCEPT'
|
|
||||||
when: jellyfin_nginx_iptables_enabled
|
|
||||||
delegate_to: "{{ jellyfin_nginx_server }}"
|
|
||||||
become: True
|
|
||||||
become_user: root
|
|
@ -32,6 +32,6 @@
|
|||||||
package:
|
package:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
loop: "{{ jellyfin_dependencies }}"
|
loop: "{{ __jellyfin_dependencies }}"
|
||||||
become: True
|
become: True
|
||||||
become_user: root
|
become_user: root
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
lvg:
|
lvg:
|
||||||
vg: "{{ jellyfin_lvm_vg }}"
|
vg: "{{ jellyfin_lvm_vg }}"
|
||||||
pvs: "{{ jellyfin_lvm_pvs | join(',') }}"
|
pvs: "{{ jellyfin_lvm_pvs | join(',') }}"
|
||||||
|
pesize: "4"
|
||||||
|
|
||||||
- name: Create logical volume '{{ jellyfin_lvm_lv }}'
|
- name: Create logical volume '{{ jellyfin_lvm_lv }}'
|
||||||
lvol:
|
lvol:
|
||||||
|
@ -6,7 +6,7 @@ After=network.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
Environment=JELLYFIN_DATA_PATH={{ jellyfin_data_dir }}
|
Environment=JELLYFIN_DATA_DIR={{ jellyfin_data_dir }}
|
||||||
Environment=JELLYFIN_CONFIG_DIR={{ jellyfin_conf_dir }}
|
Environment=JELLYFIN_CONFIG_DIR={{ jellyfin_conf_dir }}
|
||||||
Environment=JELLYFIN_LOG_DIR={{ jellyfin_log_dir }}
|
Environment=JELLYFIN_LOG_DIR={{ jellyfin_log_dir }}
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
#jinja2: lstrip_blocks: True
|
|
||||||
# {{ ansible_managed }}
|
|
||||||
upstream backend_jellyfin {
|
|
||||||
server {{ jellyfin_nginx_proxy_ip }}:{{ jellyfin_nginx_proxy_port }};
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name {{ jellyfin_base_url | urlsplit('hostname') }};
|
|
||||||
|
|
||||||
client_max_body_size 200M;
|
|
||||||
|
|
||||||
{% if jellyfin_nginx_tls_enabled %}
|
|
||||||
return 301 https://$server_name$request_uri;
|
|
||||||
{% else %}
|
|
||||||
location / {
|
|
||||||
proxy_pass http://backend_jellyfin;
|
|
||||||
proxy_set_header X-Forwarded-For $remote_addr;
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
||||||
}
|
|
||||||
|
|
||||||
{% if jellyfin_nginx_tls_enabled %}
|
|
||||||
server {
|
|
||||||
listen 443 ssl;
|
|
||||||
server_name {{ jellyfin_base_url | urlsplit('hostname') }};
|
|
||||||
|
|
||||||
client_max_body_size 200M;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://backend_jellyfin;
|
|
||||||
proxy_set_header Range $http_range;
|
|
||||||
proxy_set_header If-Range $http_if_range;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
|
|
||||||
#Next three lines allow websockets
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "upgrade";
|
|
||||||
}
|
|
||||||
|
|
||||||
ssl_certificate /etc/pki/tls/certs/{{ jellyfin_nginx_tls_cert_file }};
|
|
||||||
ssl_certificate_key /etc/pki/tls/private/{{ jellyfin_nginx_tls_key_file }};
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
8
vars/main.yml
Normal file
8
vars/main.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
__jellyfin_dependencies:
|
||||||
|
- lttng-ust
|
||||||
|
- libcurl
|
||||||
|
- openssl-libs
|
||||||
|
- krb5-libs
|
||||||
|
- libicu
|
||||||
|
- zlib
|
Loading…
Reference in New Issue
Block a user