Skip to content
Snippets Groups Projects
Commit fcbf0846 authored by Baptiste DE RENZO's avatar Baptiste DE RENZO
Browse files

Merge branch 't38020-debian-12' into 'main'

Debian 12 support, Refs #38020

See merge request sys/ansible-public!50
parents cb676640 67145f04
No related branches found
No related tags found
No related merge requests found
Showing
with 37 additions and 263 deletions
---
skyreach_system_key:
skyreach_activation_key:
localhost ansible_connection=local
[mediavault]
localhost
; vim:ft=dosini
---
skyreach_system_key:
skyreach_activation_key:
localhost ansible_connection=local
[mediaworker]
localhost
; vim:ft=dosini
---
# customer name
customer_short_name: customer
# install in offline environment
offline_mode: true
localhost ansible_connection=local
[postgres]
localhost
[mirismanager]
localhost
[mediaserver]
localhost
;[live]
;localhost
[celerity]
localhost
[mediaimport]
localhost
[msmonitor]
localhost
[munin_server]
localhost
[munin_node]
localhost
; vim:ft=dosini
---
# install in offline environment
offline_mode: true
localhost ansible_connection=local
[mediaworker]
localhost
; vim:ft=dosini
---
# activation keys
skyreach_system_key:
skyreach_activation_key:
[postgres]
ansibletest
[mirismanager]
ansibletest
[mediaserver]
ansibletest
[live]
ansibletest
[celerity]
ansibletest
[mediaworker]
ansibletest
[mediaimport]
ansibletest
[msmonitor]
ansibletest
[munin_server]
ansibletest
[munin_node]
ansibletest
#!/usr/bin/python
# Copyright: (c) 2019, Nicolas Karolak <nicolas.karolak@ubicast.eu>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {
"metadata_version": "1.1",
"status": ["preview"],
"supported_by": "community",
}
DOCUMENTATION = """
module: source_file
short_description: Source remote bash/dotenv file
description:
- This module is used to register host variables from a remote bash/dotenv-like file.
- It handles boolean value (`MY_VAR=1`) and has a basic handling of list (`MY_VAR=one,two,three`) and dictionnary (`MY_VAR=a=1;b=2;c=3`).
version_added: "2.8"
author: "Nicolas Karolak (@nikaro)"
options:
path:
description:
- Path to the file to source.
required: true
type: path
prefix:
description:
- Prefix to add to the registred variable name.
required: false
default: ""
type: str
lower:
description:
- Wether to lower or not the variable name.
required: false
default: false
type: bool
notes:
- The `check_mode` is supported.
"""
EXAMPLES = """
- name: source envsetup file
source_file:
prefix: envsetup_
path: /root/envsetup/conf.sh
lower: true
"""
RETURN = """
ansible_facts:
description: Registred vairales.
returned: on success
type: dict
sample:
key: value
"""
import os # noqa: E402
import re # noqa: E402
from ansible.module_utils.basic import AnsibleModule # noqa: E402
from ansible.module_utils.parsing.convert_bool import BOOLEANS, boolean # noqa: E402
from ansible.module_utils.six import string_types # noqa: E402
def run_module():
module_args = {
"path": {"type": "path", "required": True},
"prefix": {"type": "str", "required": False, "default": ""},
"lower": {"type": "bool", "required": False, "default": False},
}
result = {"changed": False}
module = AnsibleModule(argument_spec=module_args, supports_check_mode=True)
path = module.params["path"]
prefix = module.params["prefix"]
lower = boolean(module.params["lower"])
variables = {}
regex_valid_name = re.compile(r"^[a-zA-Z][a-zA-Z0-9_-]*$")
regex_key_value = re.compile(
r"^(?!#)(?P<key>[a-zA-Z][a-zA-Z0-9_-]*)=(?:[\'\"])?(?P<value>(?:[^\'\"\n])*)(?:[\'\"])?$",
re.MULTILINE
)
if not os.path.isfile(path):
module.fail_json(msg="'%s' does not exist or is not a file" % path, **result)
if prefix and not regex_valid_name.match(prefix):
module.fail_json(
msg="'%s' is not a valid prefix it must starts with a letter or underscore"
" character, and contains only letters, numbers and underscores" % prefix,
**result
)
with open(path) as path_fh:
# load file content and get all "key=value"
content = path_fh.read()
content_match = regex_key_value.findall(content)
for key, value in content_match:
# merge prefix + key
if prefix:
key = "%s%s" % (prefix, key)
# lower key
if lower:
key = key.lower()
# check key validity
if not regex_valid_name.match(key):
module.fail_json(
msg="'%s' is not a valid variable name it must starts with a letter or "
"underscore character, and contains only letters, numbers and underscores"
% key,
**result
)
# handle list value
if "," in value:
value = re.split("[,\n]", value)
# handle dict value
if ";" in value and "=" in value:
value = {i.split("=")[0]: i.split("=")[1] for i in value.split(";")}
# handle bool value
if isinstance(value, string_types) and value.lower() in BOOLEANS:
value = boolean(value)
# build variables dict
variables[key] = value
result["changed"] = True
if not module.check_mode:
result["ansible_facts"] = variables
module.exit_json(**result)
def main():
run_module()
if __name__ == "__main__":
main()
#!/usr/bin/env ansible-playbook #!/usr/bin/env ansible-playbook
--- ---
- name: BASE - name: BASE
hosts: all hosts: all
tags: all tags: all
roles: roles:
- base - base
...
#!/usr/bin/env ansible-playbook #!/usr/bin/env ansible-playbook
--- ---
- name: DEPLOY BENCHMARK SERVER - name: DEPLOY BENCHMARK SERVER
hosts: bench_server hosts: bench_server
pre_tasks: pre_tasks:
...@@ -32,3 +33,5 @@ ...@@ -32,3 +33,5 @@
ansible.builtin.service: ansible.builtin.service:
name: bench-worker name: bench-worker
state: restarted state: restarted
...
#!/usr/bin/env ansible-playbook #!/usr/bin/env ansible-playbook
--- ---
- name: CELERITY SERVER - name: CELERITY SERVER
hosts: celerity hosts: celerity
tags: celerity tags: celerity
...@@ -10,3 +11,5 @@ ...@@ -10,3 +11,5 @@
when: proxy_apply | d(false) when: proxy_apply | d(false)
ansible.builtin.include_role: ansible.builtin.include_role:
name: proxy name: proxy
...
#!/usr/bin/env ansible-playbook #!/usr/bin/env ansible-playbook
--- ---
- name: Let's encrypt - name: Let's encrypt
hosts: all hosts: all
tags: all tags: all
roles: roles:
- letsencrypt - letsencrypt
...
--- ---
- name: LIVE - name: LIVE
hosts: live hosts: live
gather_facts: false gather_facts: false
...@@ -7,7 +8,11 @@ ...@@ -7,7 +8,11 @@
- live - live
- import_playbook: subplays/standard-case.yml - import_playbook: subplays/standard-case.yml
when: groups['live'] | d('') | length >= 1 and ( hostvars[groups['live'][0]].ip_live is undefined or hostvars[groups['live'][0]].ip_live == "127.0.0.1" ) # playbook target mediaserver and live hosts
when: groups['live'] | d('') | length >= 1 and ( hostvars[groups['live'][0]].live_ha is undefined or hostvars[groups['live'][0]].live_ha == false )
- import_playbook: subplays/ha-case.yml - import_playbook: subplays/ha-case.yml
when: groups['live'] | d('') | length >= 1 and ( hostvars[groups['live'][0]].ip_live is defined and hostvars[groups['live'][0]].ip_live != "127.0.0.1" ) # playbook target mediaserver and live hosts
when: groups['live'] | d('') | length >= 1 and ( hostvars[groups['live'][0]].live_ha is defined and hostvars[groups['live'][0]].live_ha == true )
...
--- ---
- name: LIVE - name: LIVE
hosts: live hosts: live
tags: live tags: live
...@@ -10,27 +11,27 @@ ...@@ -10,27 +11,27 @@
- hosts: live - hosts: live
tags: live tags: live
vars: vars:
server_firewall_enabled: true live_ferm_rules_filename: live
server_ferm_rules_filename: live live_ferm_input_rules:
server_ferm_input_rules:
- proto: - proto:
- tcp - tcp
dport: dport:
- 80 - 80
- 443 - 443
- 1935 - 1935
server_ferm_output_rules: [] live_ferm_output_rules: []
server_ferm_global_settings: live_ferm_global_settings:
tasks: tasks:
- name: firewall - name: firewall
when: server_firewall_enabled
vars: vars:
ferm_rules_filename: "{{ server_ferm_rules_filename }}" ferm_rules_filename: "{{ live_ferm_rules_filename }}"
ferm_input_rules: "{{ server_ferm_input_rules }}" ferm_input_rules: "{{ live_ferm_input_rules }}"
ferm_output_rules: "{{ server_ferm_output_rules }}" ferm_output_rules: "{{ live_ferm_output_rules }}"
ferm_global_settings: "{{ server_ferm_global_settings }}" ferm_global_settings: "{{ live_ferm_global_settings }}"
ansible.builtin.include_role: ansible.builtin.include_role:
name: ferm-configure name: ferm-configure
- import_playbook: deploy-minimal.yml - import_playbook: deploy-minimal.yml
tags: live tags: live
...
--- ---
- name: Checking the live(s) server(s) live configuration state - name: Checking the live(s) server(s) live configuration state
hosts: live hosts: live
gather_facts: false gather_facts: false
...@@ -191,3 +192,5 @@ ...@@ -191,3 +192,5 @@
ansible.builtin.systemd: ansible.builtin.systemd:
name: mediaserver name: mediaserver
state: restarted state: restarted
...
--- ---
- name: Live vhost setup - name: Live vhost setup
hosts: live hosts: live
tags: live tags: live
...@@ -53,3 +54,5 @@ ...@@ -53,3 +54,5 @@
args: args:
warn: false warn: false
when: rtmp_conf_dir.stat.exists when: rtmp_conf_dir.stat.exists
...
...@@ -5,3 +5,4 @@ ...@@ -5,3 +5,4 @@
rtmp_hls_url: https://%(ms_host)s/streaming-rtmp/%(stream_id)s.m3u8 rtmp_hls_url: https://%(ms_host)s/streaming-rtmp/%(stream_id)s.m3u8
rtmp_pub_url: rtmp://%(ms_host)s/%(rtmp_app)s/%(stream_id)s rtmp_pub_url: rtmp://%(ms_host)s/%(rtmp_app)s/%(stream_id)s
deploy_case: standard deploy_case: standard
...
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment