Init: mediaserver

This commit is contained in:
2023-02-08 12:13:28 +01:00
parent 848bc9739c
commit f7c23d4ba9
31914 changed files with 6175775 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
base image=quay.io/ansible/base-test-container:1.1.0 python=3.9,2.6,2.7,3.5,3.6,3.7,3.8,3.10 seccomp=unconfined
default image=quay.io/ansible/default-test-container:4.1.0 python=3.9,2.6,2.7,3.5,3.6,3.7,3.8,3.10 seccomp=unconfined context=collection
default image=quay.io/ansible/ansible-core-test-container:4.1.0 python=3.9,2.6,2.7,3.5,3.6,3.7,3.8,3.10 seccomp=unconfined context=ansible-core
alpine3 image=quay.io/ansible/alpine3-test-container:3.1.0 python=3.9
centos6 image=quay.io/ansible/centos6-test-container:3.1.0 python=2.6 seccomp=unconfined
centos7 image=quay.io/ansible/centos7-test-container:3.1.0 python=2.7 seccomp=unconfined
centos8 image=quay.io/ansible/centos8-test-container:3.1.0 python=3.6 seccomp=unconfined
fedora33 image=quay.io/ansible/fedora33-test-container:3.1.0 python=3.9
fedora34 image=quay.io/ansible/fedora34-test-container:3.1.0 python=3.9 seccomp=unconfined
opensuse15py2 image=quay.io/ansible/opensuse15py2-test-container:3.1.0 python=2.7
opensuse15 image=quay.io/ansible/opensuse15-test-container:3.1.0 python=3.6
ubuntu1804 image=quay.io/ansible/ubuntu1804-test-container:3.1.0 python=3.6 seccomp=unconfined
ubuntu2004 image=quay.io/ansible/ubuntu2004-test-container:3.1.0 python=3.8 seccomp=unconfined

View File

@@ -0,0 +1,2 @@
ios/csr1000v collection=cisco.ios connection=ansible.netcommon.network_cli provider=aws
vyos/1.1.8 collection=vyos.vyos connection=ansible.netcommon.network_cli provider=aws

View File

@@ -0,0 +1,10 @@
freebsd/12.2 python=3.7,2.7,3.8 python_dir=/usr/local/bin provider=aws
freebsd/13.0 python=3.7,2.7,3.8,3.9 python_dir=/usr/local/bin provider=aws
freebsd python_dir=/usr/local/bin provider=aws
macos/11.1 python=3.9 python_dir=/usr/local/bin provider=parallels
macos python_dir=/usr/local/bin provider=parallels
rhel/7.9 python=2.7 provider=aws
rhel/8.4 python=3.6,3.8 provider=aws
rhel provider=aws
aix/7.2 python=2.7,3.7 python_dir=/opt/freeware/bin provider=ibmps
aix python_dir=/opt/freeware/bin provider=ibmps

View File

@@ -0,0 +1,5 @@
windows/2012 provider=aws
windows/2012-R2 provider=aws
windows/2016 provider=aws
windows/2019 provider=aws
windows/2022 provider=aws

View File

@@ -0,0 +1,21 @@
- name: Setup POSIX code coverage configuration
hosts: all
gather_facts: no
tasks:
- name: Create coverage temporary directory
file:
path: "{{ common_temp_dir }}"
mode: "{{ mode_directory }}"
state: directory
- name: Create coverage configuration file
copy:
dest: "{{ coverage_config_path }}"
content: "{{ coverage_config }}"
mode: "{{ mode_file }}"
- name: Create coverage output directory
file:
path: "{{ coverage_output_path }}"
mode: "{{ mode_directory_write }}"
state: directory

View File

@@ -0,0 +1,8 @@
- name: Teardown POSIX code coverage configuration
hosts: all
gather_facts: no
tasks:
- name: Remove coverage temporary directory
file:
path: "{{ common_temp_dir }}"
state: absent

View File

@@ -0,0 +1,9 @@
- name: Prepare POSIX hosts file
hosts: all
gather_facts: no
tasks:
- name: Add container hostname(s) to hosts file
blockinfile:
path: /etc/hosts
block: "{{ '\n'.join(hosts_entries) }}"
unsafe_writes: yes

View File

@@ -0,0 +1,10 @@
- name: Restore POSIX hosts file
hosts: all
gather_facts: no
tasks:
- name: Remove container hostname(s) from hosts file
blockinfile:
path: /etc/hosts
block: "{{ '\n'.join(hosts_entries) }}"
unsafe_writes: yes
state: absent

View File

@@ -0,0 +1,23 @@
- name: Prepare PyPI proxy configuration
hosts: all
gather_facts: no
tasks:
- name: Make sure the ~/.pip directory exists
file:
path: ~/.pip
state: directory
- name: Configure a custom index for pip based installs
copy:
content: |
[global]
index-url = {{ pypi_endpoint }}
trusted-host = {{ pypi_hostname }}
dest: ~/.pip/pip.conf
force: "{{ force }}"
- name: Configure a custom index for easy_install based installs
copy:
content: |
[easy_install]
index_url = {0}
dest: ~/.pydistutils.cfg
force: "{{ force }}"

View File

@@ -0,0 +1,12 @@
- name: Restore PyPI proxy configuration
hosts: all
gather_facts: no
tasks:
- name: Remove custom index for pip based installs
file:
path: ~/.pip/pip.conf
state: absent
- name: Remove custom index for easy_install based installs
file:
path: ~/.pydistutils.cfg
state: absent

View File

@@ -0,0 +1,18 @@
- name: Setup Windows code coverage configuration
hosts: all
gather_facts: no
tasks:
- name: Create coverage temporary directory
ansible.windows.win_file:
path: '{{ remote_temp_path }}'
state: directory
- name: Allow everyone to write to the temporary coverage directory
ansible.windows.win_acl:
path: '{{ remote_temp_path }}'
user: Everyone
rights: Modify
inherit: ContainerInherit, ObjectInherit
propagation: 'None'
type: allow
state: present

View File

@@ -0,0 +1,70 @@
- name: Teardown Windows code coverage configuration
hosts: all
gather_facts: no
tasks:
- name: Zip up all coverage files
ansible.windows.win_shell: |
$coverage_dir = '{{ remote_temp_path }}'
$zip_file = Join-Path -Path $coverage_dir -ChildPath 'coverage.zip'
if (Test-Path -LiteralPath $zip_file) {
Remove-Item -LiteralPath $zip_file -Force
}
$coverage_files = Get-ChildItem -LiteralPath $coverage_dir -Include '*=coverage*' -File
$legacy = $false
try {
# Requires .NET 4.5+ which isn't present on older WIndows versions. Remove once 2008/R2 is EOL.
# We also can't use the Shell.Application as it will fail on GUI-less servers (Server Core).
Add-Type -AssemblyName System.IO.Compression -ErrorAction Stop > $null
} catch {
$legacy = $true
}
if ($legacy) {
New-Item -Path $zip_file -ItemType File > $null
$shell = New-Object -ComObject Shell.Application
$zip = $shell.Namespace($zip_file)
foreach ($file in $coverage_files) {
$zip.CopyHere($file.FullName)
}
} else {
$fs = New-Object -TypeName System.IO.FileStream -ArgumentList $zip_file, 'CreateNew'
try {
$archive = New-Object -TypeName System.IO.Compression.ZipArchive -ArgumentList @(
$fs,
[System.IO.Compression.ZipArchiveMode]::Create
)
try {
foreach ($file in $coverage_files) {
$archive_entry = $archive.CreateEntry($file.Name, 'Optimal')
$entry_fs = $archive_entry.Open()
try {
$file_fs = [System.IO.File]::OpenRead($file.FullName)
try {
$file_fs.CopyTo($entry_fs)
} finally {
$file_fs.Dispose()
}
} finally {
$entry_fs.Dispose()
}
}
} finally {
$archive.Dispose()
}
} finally {
$fs.Dispose()
}
}
- name: Fetch coverage zip
fetch:
src: '{{ remote_temp_path }}\coverage.zip'
dest: '{{ local_temp_path }}/{{ inventory_hostname }}.zip'
flat: yes
- name: Remove temporary coverage directory
ansible.windows.win_file:
path: '{{ remote_temp_path }}'
state: absent

View File

@@ -0,0 +1,34 @@
<#
.SYNOPSIS
Add one or more hosts entries to the Windows hosts file.
.PARAMETER Hosts
A list of hosts entries, delimited by '|'.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, Position=0)][String]$Hosts
)
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
Write-Verbose -Message "Adding host file entries"
$hosts_entries = $Hosts.Split('|')
$hosts_file = "$env:SystemRoot\System32\drivers\etc\hosts"
$hosts_file_lines = [System.IO.File]::ReadAllLines($hosts_file)
$changed = $false
foreach ($entry in $hosts_entries) {
if ($entry -notin $hosts_file_lines) {
$hosts_file_lines += $entry
$changed = $true
}
}
if ($changed) {
Write-Verbose -Message "Host file is missing entries, adding missing entries"
[System.IO.File]::WriteAllLines($hosts_file, $hosts_file_lines)
}

View File

@@ -0,0 +1,7 @@
- name: Prepare Windows hosts file
hosts: all
gather_facts: no
tasks:
- name: Add container hostname(s) to hosts file
script:
cmd: "\"{{ playbook_dir }}/windows_hosts_prepare.ps1\" -Hosts \"{{ '|'.join(hosts_entries) }}\""

View File

@@ -0,0 +1,37 @@
<#
.SYNOPSIS
Remove one or more hosts entries from the Windows hosts file.
.PARAMETER Hosts
A list of hosts entries, delimited by '|'.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, Position=0)][String]$Hosts
)
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
Write-Verbose -Message "Removing host file entries"
$hosts_entries = $Hosts.Split('|')
$hosts_file = "$env:SystemRoot\System32\drivers\etc\hosts"
$hosts_file_lines = [System.IO.File]::ReadAllLines($hosts_file)
$changed = $false
$new_lines = [System.Collections.ArrayList]@()
foreach ($host_line in $hosts_file_lines) {
if ($host_line -in $hosts_entries) {
$changed = $true
} else {
$new_lines += $host_line
}
}
if ($changed) {
Write-Verbose -Message "Host file has extra entries, removing extra entries"
[System.IO.File]::WriteAllLines($hosts_file, $new_lines)
}

View File

@@ -0,0 +1,7 @@
- name: Restore Windows hosts file
hosts: all
gather_facts: no
tasks:
- name: Remove container hostname(s) from hosts file
script:
cmd: "\"{{ playbook_dir }}/windows_hosts_restore.ps1\" -Hosts \"{{ '|'.join(hosts_entries) }}\""

View File

@@ -0,0 +1,9 @@
[pytest]
xfail_strict = true
mock_use_standalone_module = true
# It was decided to stick with "legacy" (aka "xunit1") for now.
# Currently used pytest versions all support xunit2 format too.
# Except the one used under Python 2.6 - it doesn't process this option
# at all. Ref:
# https://github.com/ansible/ansible/pull/66445#discussion_r372530176
junit_family = xunit1

View File

@@ -0,0 +1,13 @@
# Note: this requirements.txt file is used to specify what dependencies are
# needed to make the package run rather than for deployment of a tested set of
# packages. Thus, this should be the loosest set possible (only required
# packages, not optional ones, and with the widest range of versions that could
# be suitable)
jinja2
PyYAML
cryptography
packaging
# NOTE: resolvelib 0.x version bumps should be considered major/breaking
# NOTE: and we should update the upper cap with care, at least until 1.0
# NOTE: Ref: https://github.com/sarugaku/resolvelib/issues/69
resolvelib >= 0.5.3, < 0.6.0 # dependency resolver used by ansible-galaxy

View File

@@ -0,0 +1,30 @@
# do not add a cryptography or pyopenssl constraint to this file, they require special handling, see get_cryptography_requirements in python_requirements.py
# do not add a coverage constraint to this file, it is handled internally by ansible-test
packaging < 21.0 ; python_version < '3.6' # packaging 21.0 requires Python 3.6 or newer
six < 1.14.0 ; python_version < '2.7' # six 1.14.0 drops support for python 2.6
jinja2 < 2.11 ; python_version < '2.7' # jinja2 2.11 and later require python 2.7 or later
urllib3 < 1.24 ; python_version < '2.7' # urllib3 1.24 and later require python 2.7 or later
pywinrm >= 0.3.0 # message encryption support
wheel < 0.30.0 ; python_version < '2.7' # wheel 0.30.0 and later require python 2.7 or later
idna < 2.6, >= 2.5 # linode requires idna < 2.9, >= 2.5, requests requires idna < 2.6, but cryptography will cause the latest version to be installed instead
paramiko < 2.4.0 ; python_version < '2.7' # paramiko 2.4.0 drops support for python 2.6
pytest < 3.3.0, >= 3.1.0 ; python_version < '2.7' # pytest 3.3.0 drops support for python 2.6
pytest < 5.0.0, >= 4.5.0 ; python_version == '2.7' # pytest 5.0.0 and later will no longer support python 2.7
pytest >= 4.5.0 ; python_version > '2.7' # pytest 4.5.0 added support for --strict-markers
pytest-forked < 1.0.2 ; python_version < '2.7' # pytest-forked 1.0.2 and later require python 2.7 or later
pytest-forked >= 1.0.2 ; python_version >= '2.7' # pytest-forked before 1.0.2 does not work with pytest 4.2.0+ (which requires python 2.7+)
ntlm-auth >= 1.3.0 # message encryption support using cryptography
requests < 2.20.0 ; python_version < '2.7' # requests 2.20.0 drops support for python 2.6
requests-ntlm >= 1.1.0 # message encryption support
requests-credssp >= 0.1.0 # message encryption support
virtualenv < 16.0.0 ; python_version < '2.7' # virtualenv 16.0.0 and later require python 2.7 or later
pyparsing < 3.0.0 ; python_version < '3.5' # pyparsing 3 and later require python 3.5 or later
pyyaml < 5.1 ; python_version < '2.7' # pyyaml 5.1 and later require python 2.7 or later
pycparser < 2.19 ; python_version < '2.7' # pycparser 2.19 and later require python 2.7 or later
mock >= 2.0.0 # needed for features backported from Python 3.6 unittest.mock (assert_called, assert_called_once...)
pytest-mock >= 1.4.0 # needed for mock_use_standalone_module pytest option
xmltodict < 0.12.0 ; python_version < '2.7' # xmltodict 0.12.0 and later require python 2.7 or later
setuptools < 37 ; python_version == '2.6' # setuptools 37 and later require python 2.7 or later
setuptools < 45 ; python_version == '2.7' # setuptools 45 and later require python 3.5 or later
pyspnego >= 0.1.6 ; python_version >= '3.10' # bug in older releases breaks on Python 3.10
MarkupSafe < 2.0.0 ; python_version < '3.6' # MarkupSafe >= 2.0.0. requires Python >= 3.6

View File

@@ -0,0 +1,7 @@
jinja2 == 3.0.1 # ansible-core requirement
pyyaml == 5.4.1 # ansible-core requirement
packaging == 21.0 # ansible-doc requirement
# dependencies
MarkupSafe == 2.0.1
pyparsing == 2.4.7

View File

@@ -0,0 +1,9 @@
antsibull-changelog == 0.9.0
# dependencies
pyyaml == 5.4.1
docutils == 0.17.1
packaging == 21.0
pyparsing == 2.4.7
rstcheck == 3.3.1
semantic-version == 2.8.5

View File

@@ -0,0 +1 @@
pycodestyle == 2.6.0

View File

@@ -0,0 +1,44 @@
param (
[Switch]
$IsContainer
)
#Requires -Version 6
Set-StrictMode -Version 2.0
$ErrorActionPreference = "Stop"
$ProgressPreference = 'SilentlyContinue'
Function Install-PSModule {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[String]
$Name,
[Parameter(Mandatory=$true)]
[Version]
$RequiredVersion
)
# In case PSGallery is down we check if the module is already installed.
$installedModule = Get-Module -Name $Name -ListAvailable | Where-Object Version -eq $RequiredVersion
if (-not $installedModule) {
Install-Module -Name $Name -RequiredVersion $RequiredVersion -Scope CurrentUser
}
}
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-PSModule -Name PSScriptAnalyzer -RequiredVersion 1.18.0
if ($IsContainer) {
# PSScriptAnalyzer contain lots of json files for the UseCompatibleCommands check. We don't use this rule so by
# removing the contents we can save 200MB in the docker image (or more in the future).
# https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/UseCompatibleCommands.md
$pssaPath = (Get-Module -ListAvailable -Name PSScriptAnalyzer).ModuleBase
$compatPath = Join-Path -Path $pssaPath -ChildPath compatibility_profiles -AdditionalChildPath '*'
Remove-Item -Path $compatPath -Recurse -Force
}
# Installed the PSCustomUseLiteralPath rule
Install-PSModule -Name PSSA-PSCustomUseLiteralPath -RequiredVersion 0.1.1

View File

@@ -0,0 +1,10 @@
pylint == 2.9.3
pyyaml == 5.4.1 # needed for collection_detail.py
# dependencies
astroid == 2.6.6
isort == 5.9.3
lazy-object-proxy == 1.6.0
mccabe == 0.6.1
toml == 0.10.2
wrapt == 1.12.1

View File

@@ -0,0 +1,2 @@
pyyaml == 5.4.1
voluptuous == 0.12.1

View File

@@ -0,0 +1,6 @@
jinja2 == 3.0.1 # ansible-core requirement
pyyaml == 5.4.1 # needed for collection_detail.py
voluptuous == 0.12.1
# dependencies
MarkupSafe == 2.0.1

View File

@@ -0,0 +1,5 @@
yamllint == 1.26.0
# dependencies
pathspec == 0.9.0
pyyaml == 5.4.1

View File

@@ -0,0 +1,5 @@
mock
pytest
pytest-mock
pytest-xdist
pyyaml # required by the collection loader (only needed for collections)

View File

@@ -0,0 +1,5 @@
ntlm-auth
requests-ntlm
requests-credssp
pypsrp
pywinrm[credssp]