mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Migration of Podman modules from Ansible to Containers
This commit is contained in:
parent
f191f94e55
commit
dc13dce52a
50 changed files with 3530 additions and 2 deletions
387
.gitignore
vendored
Normal file
387
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,387 @@
|
||||||
|
|
||||||
|
# Created by https://www.gitignore.io/api/git,linux,pydev,python,windows,pycharm+all,jupyternotebook,vim,webstorm,emacs,dotenv
|
||||||
|
# Edit at https://www.gitignore.io/?templates=git,linux,pydev,python,windows,pycharm+all,jupyternotebook,vim,webstorm,emacs,dotenv
|
||||||
|
|
||||||
|
### dotenv ###
|
||||||
|
.env
|
||||||
|
|
||||||
|
### Emacs ###
|
||||||
|
# -*- mode: gitignore; -*-
|
||||||
|
*~
|
||||||
|
\#*\#
|
||||||
|
/.emacs.desktop
|
||||||
|
/.emacs.desktop.lock
|
||||||
|
*.elc
|
||||||
|
auto-save-list
|
||||||
|
tramp
|
||||||
|
.\#*
|
||||||
|
|
||||||
|
# Org-mode
|
||||||
|
.org-id-locations
|
||||||
|
*_archive
|
||||||
|
|
||||||
|
# flymake-mode
|
||||||
|
*_flymake.*
|
||||||
|
|
||||||
|
# eshell files
|
||||||
|
/eshell/history
|
||||||
|
/eshell/lastdir
|
||||||
|
|
||||||
|
# elpa packages
|
||||||
|
/elpa/
|
||||||
|
|
||||||
|
# reftex files
|
||||||
|
*.rel
|
||||||
|
|
||||||
|
# AUCTeX auto folder
|
||||||
|
/auto/
|
||||||
|
|
||||||
|
# cask packages
|
||||||
|
.cask/
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# Flycheck
|
||||||
|
flycheck_*.el
|
||||||
|
|
||||||
|
# server auth directory
|
||||||
|
/server/
|
||||||
|
|
||||||
|
# projectiles files
|
||||||
|
.projectile
|
||||||
|
|
||||||
|
# directory configuration
|
||||||
|
.dir-locals.el
|
||||||
|
|
||||||
|
# network security
|
||||||
|
/network-security.data
|
||||||
|
|
||||||
|
|
||||||
|
### Git ###
|
||||||
|
# Created by git for backups. To disable backups in Git:
|
||||||
|
# $ git config --global mergetool.keepBackup false
|
||||||
|
*.orig
|
||||||
|
|
||||||
|
# Created by git when using merge tools for conflicts
|
||||||
|
*.BACKUP.*
|
||||||
|
*.BASE.*
|
||||||
|
*.LOCAL.*
|
||||||
|
*.REMOTE.*
|
||||||
|
*_BACKUP_*.txt
|
||||||
|
*_BASE_*.txt
|
||||||
|
*_LOCAL_*.txt
|
||||||
|
*_REMOTE_*.txt
|
||||||
|
|
||||||
|
#!! ERROR: jupyternotebook is undefined. Use list command to see defined gitignore types !!#
|
||||||
|
|
||||||
|
### Linux ###
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
### PyCharm+all ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
### PyCharm+all Patch ###
|
||||||
|
# Ignores the whole .idea folder and all .iml files
|
||||||
|
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
|
||||||
|
|
||||||
|
*.iml
|
||||||
|
modules.xml
|
||||||
|
.idea/misc.xml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
# Sonarlint plugin
|
||||||
|
.idea/sonarlint
|
||||||
|
|
||||||
|
### pydev ###
|
||||||
|
.pydevproject
|
||||||
|
|
||||||
|
### Python ###
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
pip-wheel-metadata/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# Mr Developer
|
||||||
|
.mr.developer.cfg
|
||||||
|
.project
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
### Vim ###
|
||||||
|
# Swap
|
||||||
|
[._]*.s[a-v][a-z]
|
||||||
|
[._]*.sw[a-p]
|
||||||
|
[._]s[a-rt-v][a-z]
|
||||||
|
[._]ss[a-gi-z]
|
||||||
|
[._]sw[a-p]
|
||||||
|
|
||||||
|
# Session
|
||||||
|
Session.vim
|
||||||
|
Sessionx.vim
|
||||||
|
|
||||||
|
# Temporary
|
||||||
|
.netrwhist
|
||||||
|
# Auto-generated tag files
|
||||||
|
tags
|
||||||
|
# Persistent undo
|
||||||
|
[._]*.un~
|
||||||
|
|
||||||
|
### WebStorm ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
|
||||||
|
### WebStorm Patch ###
|
||||||
|
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||||
|
|
||||||
|
# *.iml
|
||||||
|
# modules.xml
|
||||||
|
# .idea/misc.xml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# Sonarlint plugin
|
||||||
|
.idea/**/sonarlint/
|
||||||
|
|
||||||
|
# SonarQube Plugin
|
||||||
|
.idea/**/sonarIssues.xml
|
||||||
|
|
||||||
|
# Markdown Navigator plugin
|
||||||
|
.idea/**/markdown-navigator.xml
|
||||||
|
.idea/**/markdown-navigator/
|
||||||
|
|
||||||
|
### Windows ###
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
Thumbs.db:encryptable
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
# End of https://www.gitignore.io/api/git,linux,pydev,python,windows,pycharm+all,jupyternotebook,vim,webstorm,emacs,dotenv
|
||||||
675
COPYING
Normal file
675
COPYING
Normal file
|
|
@ -0,0 +1,675 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
# ansible-podman-collections
|
[](https://github.com/ansible-collection-migration/containers.podman/actions?query=workflow%3A%22Collection%20test%20suite%22)
|
||||||
Repository for Ansible content that can include playbooks, roles, modules, and plugins for use with the Podman tool
|
|
||||||
|
Ansible Collection: containers.podman
|
||||||
|
=================================================
|
||||||
23
galaxy.yml
Normal file
23
galaxy.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
namespace: containers
|
||||||
|
name: podman
|
||||||
|
version: 0.1.0
|
||||||
|
readme: README.md
|
||||||
|
authors: Podman
|
||||||
|
description: Podman container Ansible modules
|
||||||
|
license: Apache-2.0
|
||||||
|
license_file: COPYING
|
||||||
|
tags:
|
||||||
|
- containers
|
||||||
|
- podman
|
||||||
|
- libpod
|
||||||
|
dependencies: {}
|
||||||
|
repository: https://github.com/containers/ansible-podman-collections.git
|
||||||
|
documentation: https://github.com/containers/ansible-podman-collections
|
||||||
|
homepage: https://github.com/containers/ansible-podman-collections
|
||||||
|
issues: https://github.com/containers/ansible-podman-collections/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
|
||||||
|
build_ignore:
|
||||||
|
- build_artifact/
|
||||||
|
- "*.tar.gz"
|
||||||
|
- zuul.yaml
|
||||||
|
- .gitignore
|
||||||
|
|
||||||
0
plugins/connection/__init__.py
Normal file
0
plugins/connection/__init__.py
Normal file
160
plugins/connection/buildah.py
Normal file
160
plugins/connection/buildah.py
Normal file
|
|
@ -0,0 +1,160 @@
|
||||||
|
# Based on the docker connection plugin
|
||||||
|
# Copyright (c) 2017 Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
#
|
||||||
|
# Connection plugin for building container images using buildah tool
|
||||||
|
# https://github.com/projectatomic/buildah
|
||||||
|
#
|
||||||
|
# Written by: Tomas Tomecek (https://github.com/TomasTomecek)
|
||||||
|
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
connection: buildah
|
||||||
|
short_description: Interact with an existing buildah container
|
||||||
|
description:
|
||||||
|
- Run commands or put/fetch files to an existing container using buildah tool.
|
||||||
|
author: Tomas Tomecek (ttomecek@redhat.com)
|
||||||
|
options:
|
||||||
|
remote_addr:
|
||||||
|
description:
|
||||||
|
- The ID of the container you want to access.
|
||||||
|
default: inventory_hostname
|
||||||
|
vars:
|
||||||
|
- name: ansible_host
|
||||||
|
# keyword:
|
||||||
|
# - name: hosts
|
||||||
|
remote_user:
|
||||||
|
description:
|
||||||
|
- User specified via name or ID which is used to execute commands inside the container.
|
||||||
|
ini:
|
||||||
|
- section: defaults
|
||||||
|
key: remote_user
|
||||||
|
env:
|
||||||
|
- name: ANSIBLE_REMOTE_USER
|
||||||
|
vars:
|
||||||
|
- name: ansible_user
|
||||||
|
# keyword:
|
||||||
|
# - name: remote_user
|
||||||
|
'''
|
||||||
|
|
||||||
|
import shlex
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
import ansible.constants as C
|
||||||
|
from ansible.module_utils._text import to_bytes, to_native
|
||||||
|
from ansible.plugins.connection import ConnectionBase, ensure_connect
|
||||||
|
from ansible.utils.display import Display
|
||||||
|
|
||||||
|
display = Display()
|
||||||
|
|
||||||
|
|
||||||
|
# this _has to be_ named Connection
|
||||||
|
class Connection(ConnectionBase):
|
||||||
|
"""
|
||||||
|
This is a connection plugin for buildah: it uses buildah binary to interact with the containers
|
||||||
|
"""
|
||||||
|
|
||||||
|
# String used to identify this Connection class from other classes
|
||||||
|
transport = 'containers.podman.buildah'
|
||||||
|
has_pipelining = True
|
||||||
|
|
||||||
|
def __init__(self, play_context, new_stdin, *args, **kwargs):
|
||||||
|
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
||||||
|
|
||||||
|
self._container_id = self._play_context.remote_addr
|
||||||
|
self._connected = False
|
||||||
|
# container filesystem will be mounted here on host
|
||||||
|
self._mount_point = None
|
||||||
|
# `buildah inspect` doesn't contain info about what the default user is -- if it's not
|
||||||
|
# set, it's empty
|
||||||
|
self.user = self._play_context.remote_user
|
||||||
|
|
||||||
|
def _set_user(self):
|
||||||
|
self._buildah(b"config", [b"--user=" + to_bytes(self.user, errors='surrogate_or_strict')])
|
||||||
|
|
||||||
|
def _buildah(self, cmd, cmd_args=None, in_data=None):
|
||||||
|
"""
|
||||||
|
run buildah executable
|
||||||
|
|
||||||
|
:param cmd: buildah's command to execute (str)
|
||||||
|
:param cmd_args: list of arguments to pass to the command (list of str/bytes)
|
||||||
|
:param in_data: data passed to buildah's stdin
|
||||||
|
:return: return code, stdout, stderr
|
||||||
|
"""
|
||||||
|
local_cmd = ['buildah', cmd, '--', self._container_id]
|
||||||
|
if cmd_args:
|
||||||
|
local_cmd += cmd_args
|
||||||
|
local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
|
||||||
|
|
||||||
|
display.vvv("RUN %s" % (local_cmd,), host=self._container_id)
|
||||||
|
p = subprocess.Popen(local_cmd, shell=False, stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
|
stdout, stderr = p.communicate(input=in_data)
|
||||||
|
stdout = to_bytes(stdout, errors='surrogate_or_strict')
|
||||||
|
stderr = to_bytes(stderr, errors='surrogate_or_strict')
|
||||||
|
return p.returncode, stdout, stderr
|
||||||
|
|
||||||
|
def _connect(self):
|
||||||
|
"""
|
||||||
|
no persistent connection is being maintained, mount container's filesystem
|
||||||
|
so we can easily access it
|
||||||
|
"""
|
||||||
|
super(Connection, self)._connect()
|
||||||
|
rc, self._mount_point, stderr = self._buildah("mount")
|
||||||
|
self._mount_point = self._mount_point.strip()
|
||||||
|
display.vvvvv("MOUNTPOINT %s RC %s STDERR %r" % (self._mount_point, rc, stderr))
|
||||||
|
self._connected = True
|
||||||
|
|
||||||
|
@ensure_connect
|
||||||
|
def exec_command(self, cmd, in_data=None, sudoable=False):
|
||||||
|
""" run specified command in a running OCI container using buildah """
|
||||||
|
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
|
||||||
|
|
||||||
|
# shlex.split has a bug with text strings on Python-2.6 and can only handle text strings on Python-3
|
||||||
|
cmd_args_list = shlex.split(to_native(cmd, errors='surrogate_or_strict'))
|
||||||
|
|
||||||
|
rc, stdout, stderr = self._buildah("run", cmd_args_list, in_data)
|
||||||
|
|
||||||
|
display.vvvvv("STDOUT %r STDERR %r" % (stderr, stderr))
|
||||||
|
return rc, stdout, stderr
|
||||||
|
|
||||||
|
def put_file(self, in_path, out_path):
|
||||||
|
""" Place a local file located in 'in_path' inside container at 'out_path' """
|
||||||
|
super(Connection, self).put_file(in_path, out_path)
|
||||||
|
display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._container_id)
|
||||||
|
|
||||||
|
real_out_path = self._mount_point + to_bytes(out_path, errors='surrogate_or_strict')
|
||||||
|
shutil.copyfile(
|
||||||
|
to_bytes(in_path, errors='surrogate_or_strict'),
|
||||||
|
to_bytes(real_out_path, errors='surrogate_or_strict')
|
||||||
|
)
|
||||||
|
# alternatively, this can be implemented using `buildah copy`:
|
||||||
|
# rc, stdout, stderr = self._buildah(
|
||||||
|
# "copy",
|
||||||
|
# [to_bytes(in_path, errors='surrogate_or_strict'),
|
||||||
|
# to_bytes(out_path, errors='surrogate_or_strict')]
|
||||||
|
# )
|
||||||
|
|
||||||
|
def fetch_file(self, in_path, out_path):
|
||||||
|
""" obtain file specified via 'in_path' from the container and place it at 'out_path' """
|
||||||
|
super(Connection, self).fetch_file(in_path, out_path)
|
||||||
|
display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._container_id)
|
||||||
|
|
||||||
|
real_in_path = self._mount_point + to_bytes(in_path, errors='surrogate_or_strict')
|
||||||
|
shutil.copyfile(
|
||||||
|
to_bytes(real_in_path, errors='surrogate_or_strict'),
|
||||||
|
to_bytes(out_path, errors='surrogate_or_strict')
|
||||||
|
)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
""" unmount container's filesystem """
|
||||||
|
super(Connection, self).close()
|
||||||
|
rc, stdout, stderr = self._buildah("umount")
|
||||||
|
display.vvvvv("RC %s STDOUT %r STDERR %r" % (rc, stdout, stderr))
|
||||||
|
self._connected = False
|
||||||
207
plugins/connection/podman.py
Normal file
207
plugins/connection/podman.py
Normal file
|
|
@ -0,0 +1,207 @@
|
||||||
|
# Based on the buildah connection plugin
|
||||||
|
# Copyright (c) 2018 Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
#
|
||||||
|
# Connection plugin to interact with existing podman containers.
|
||||||
|
# https://github.com/containers/libpod
|
||||||
|
#
|
||||||
|
# Written by: Tomas Tomecek (https://github.com/TomasTomecek)
|
||||||
|
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import distutils.spawn
|
||||||
|
import shlex
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from ansible.errors import AnsibleError
|
||||||
|
from ansible.module_utils._text import to_bytes, to_native
|
||||||
|
from ansible.plugins.connection import ConnectionBase, ensure_connect
|
||||||
|
from ansible.utils.display import Display
|
||||||
|
|
||||||
|
display = Display()
|
||||||
|
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
author: Tomas Tomecek (ttomecek@redhat.com)
|
||||||
|
connection: podman
|
||||||
|
short_description: Interact with an existing podman container
|
||||||
|
description:
|
||||||
|
- Run commands or put/fetch files to an existing container using podman tool.
|
||||||
|
options:
|
||||||
|
remote_addr:
|
||||||
|
description:
|
||||||
|
- The ID of the container you want to access.
|
||||||
|
default: inventory_hostname
|
||||||
|
vars:
|
||||||
|
- name: ansible_host
|
||||||
|
remote_user:
|
||||||
|
description:
|
||||||
|
- User specified via name or UID which is used to execute commands inside the container. If you
|
||||||
|
specify the user via UID, you must set C(ANSIBLE_REMOTE_TMP) to a path that exits
|
||||||
|
inside the container and is writable by Ansible.
|
||||||
|
ini:
|
||||||
|
- section: defaults
|
||||||
|
key: remote_user
|
||||||
|
env:
|
||||||
|
- name: ANSIBLE_REMOTE_USER
|
||||||
|
vars:
|
||||||
|
- name: ansible_user
|
||||||
|
podman_extra_args:
|
||||||
|
description:
|
||||||
|
- Extra arguments to pass to the podman command line.
|
||||||
|
default: ''
|
||||||
|
ini:
|
||||||
|
- section: defaults
|
||||||
|
key: podman_extra_args
|
||||||
|
vars:
|
||||||
|
- name: ansible_podman_extra_args
|
||||||
|
env:
|
||||||
|
- name: ANSIBLE_PODMAN_EXTRA_ARGS
|
||||||
|
podman_executable:
|
||||||
|
description:
|
||||||
|
- Executable for podman command.
|
||||||
|
default: podman
|
||||||
|
vars:
|
||||||
|
- name: ansible_podman_executable
|
||||||
|
env:
|
||||||
|
- name: ANSIBLE_PODMAN_EXECUTABLE
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
# this _has to be_ named Connection
|
||||||
|
class Connection(ConnectionBase):
|
||||||
|
"""
|
||||||
|
This is a connection plugin for podman. It uses podman binary to interact with the containers
|
||||||
|
"""
|
||||||
|
|
||||||
|
# String used to identify this Connection class from other classes
|
||||||
|
transport = 'containers.podman.podman'
|
||||||
|
has_pipelining = True
|
||||||
|
|
||||||
|
def __init__(self, play_context, new_stdin, *args, **kwargs):
|
||||||
|
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
||||||
|
|
||||||
|
self._container_id = self._play_context.remote_addr
|
||||||
|
self._connected = False
|
||||||
|
# container filesystem will be mounted here on host
|
||||||
|
self._mount_point = None
|
||||||
|
self.user = self._play_context.remote_user
|
||||||
|
|
||||||
|
def _podman(self, cmd, cmd_args=None, in_data=None, use_container_id=True):
|
||||||
|
"""
|
||||||
|
run podman executable
|
||||||
|
|
||||||
|
:param cmd: podman's command to execute (str)
|
||||||
|
:param cmd_args: list of arguments to pass to the command (list of str/bytes)
|
||||||
|
:param in_data: data passed to podman's stdin
|
||||||
|
:return: return code, stdout, stderr
|
||||||
|
"""
|
||||||
|
podman_exec = self.get_option('podman_executable')
|
||||||
|
podman_cmd = distutils.spawn.find_executable(podman_exec)
|
||||||
|
if not podman_cmd:
|
||||||
|
raise AnsibleError("%s command not found in PATH" % podman_exec)
|
||||||
|
local_cmd = [podman_cmd]
|
||||||
|
if self.get_option('podman_extra_args'):
|
||||||
|
local_cmd += shlex.split(
|
||||||
|
to_native(
|
||||||
|
self.get_option('podman_extra_args'),
|
||||||
|
errors='surrogate_or_strict'))
|
||||||
|
local_cmd.append(cmd)
|
||||||
|
if use_container_id:
|
||||||
|
local_cmd.append(self._container_id)
|
||||||
|
if cmd_args:
|
||||||
|
local_cmd += cmd_args
|
||||||
|
local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
|
||||||
|
|
||||||
|
display.vvv("RUN %s" % (local_cmd,), host=self._container_id)
|
||||||
|
p = subprocess.Popen(local_cmd, shell=False, stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
|
stdout, stderr = p.communicate(input=in_data)
|
||||||
|
display.vvvvv("STDOUT %s" % stdout)
|
||||||
|
display.vvvvv("STDERR %s" % stderr)
|
||||||
|
display.vvvvv("RC CODE %s" % p.returncode)
|
||||||
|
stdout = to_bytes(stdout, errors='surrogate_or_strict')
|
||||||
|
stderr = to_bytes(stderr, errors='surrogate_or_strict')
|
||||||
|
return p.returncode, stdout, stderr
|
||||||
|
|
||||||
|
def _connect(self):
|
||||||
|
"""
|
||||||
|
no persistent connection is being maintained, mount container's filesystem
|
||||||
|
so we can easily access it
|
||||||
|
"""
|
||||||
|
super(Connection, self)._connect()
|
||||||
|
rc, self._mount_point, stderr = self._podman("mount")
|
||||||
|
if rc != 0:
|
||||||
|
display.v("Failed to mount container %s: %s" % (self._container_id, stderr.strip()))
|
||||||
|
else:
|
||||||
|
self._mount_point = self._mount_point.strip()
|
||||||
|
display.vvvvv("MOUNTPOINT %s RC %s STDERR %r" % (self._mount_point, rc, stderr))
|
||||||
|
self._connected = True
|
||||||
|
|
||||||
|
@ensure_connect
|
||||||
|
def exec_command(self, cmd, in_data=None, sudoable=False):
|
||||||
|
""" run specified command in a running OCI container using podman """
|
||||||
|
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
|
||||||
|
|
||||||
|
# shlex.split has a bug with text strings on Python-2.6 and can only handle text strings on Python-3
|
||||||
|
cmd_args_list = shlex.split(to_native(cmd, errors='surrogate_or_strict'))
|
||||||
|
if self.user:
|
||||||
|
cmd_args_list += ["--user", self.user]
|
||||||
|
|
||||||
|
rc, stdout, stderr = self._podman("exec", cmd_args_list, in_data)
|
||||||
|
|
||||||
|
display.vvvvv("STDOUT %r STDERR %r" % (stderr, stderr))
|
||||||
|
return rc, stdout, stderr
|
||||||
|
|
||||||
|
def put_file(self, in_path, out_path):
|
||||||
|
""" Place a local file located in 'in_path' inside container at 'out_path' """
|
||||||
|
super(Connection, self).put_file(in_path, out_path)
|
||||||
|
display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._container_id)
|
||||||
|
if not self._mount_point:
|
||||||
|
rc, stdout, stderr = self._podman(
|
||||||
|
"cp", [in_path, self._container_id + ":" + out_path], use_container_id=False
|
||||||
|
)
|
||||||
|
if rc != 0:
|
||||||
|
if 'cannot copy into running rootless container with pause set' in to_native(stderr):
|
||||||
|
rc, stdout, stderr = self._podman(
|
||||||
|
"cp", ["--pause=false", in_path, self._container_id + ":" + out_path], use_container_id=False
|
||||||
|
)
|
||||||
|
if rc != 0:
|
||||||
|
raise AnsibleError(
|
||||||
|
"Failed to copy file from %s to %s in container %s\n%s" % (
|
||||||
|
in_path, out_path, self._container_id, stderr)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
real_out_path = self._mount_point + to_bytes(out_path, errors='surrogate_or_strict')
|
||||||
|
shutil.copyfile(
|
||||||
|
to_bytes(in_path, errors='surrogate_or_strict'),
|
||||||
|
to_bytes(real_out_path, errors='surrogate_or_strict')
|
||||||
|
)
|
||||||
|
|
||||||
|
def fetch_file(self, in_path, out_path):
|
||||||
|
""" obtain file specified via 'in_path' from the container and place it at 'out_path' """
|
||||||
|
super(Connection, self).fetch_file(in_path, out_path)
|
||||||
|
display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._container_id)
|
||||||
|
if not self._mount_point:
|
||||||
|
rc, stdout, stderr = self._podman(
|
||||||
|
"cp", [self._container_id + ":" + in_path, out_path], use_container_id=False)
|
||||||
|
if rc != 0:
|
||||||
|
raise AnsibleError("Failed to fetch file from %s to %s from container %s\n%s" % (
|
||||||
|
in_path, out_path, self._container_id, stderr))
|
||||||
|
else:
|
||||||
|
real_in_path = self._mount_point + to_bytes(in_path, errors='surrogate_or_strict')
|
||||||
|
shutil.copyfile(
|
||||||
|
to_bytes(real_in_path, errors='surrogate_or_strict'),
|
||||||
|
to_bytes(out_path, errors='surrogate_or_strict')
|
||||||
|
)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
""" unmount container's filesystem """
|
||||||
|
super(Connection, self).close()
|
||||||
|
# we actually don't need to unmount since the container is mounted anyway
|
||||||
|
# rc, stdout, stderr = self._podman("umount")
|
||||||
|
# display.vvvvv("RC %s STDOUT %r STDERR %r" % (rc, stdout, stderr))
|
||||||
|
self._connected = False
|
||||||
0
plugins/module_utils/__init__.py
Normal file
0
plugins/module_utils/__init__.py
Normal file
0
plugins/module_utils/podman/__init__.py
Normal file
0
plugins/module_utils/podman/__init__.py
Normal file
19
plugins/module_utils/podman/common.py
Normal file
19
plugins/module_utils/podman/common.py
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2019 Ansible Project
|
||||||
|
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
def run_podman_command(module, executable='podman', args=None, expected_rc=0, ignore_errors=False):
|
||||||
|
if not isinstance(executable, list):
|
||||||
|
command = [executable]
|
||||||
|
if args is not None:
|
||||||
|
command.extend(args)
|
||||||
|
rc, out, err = module.run_command(command)
|
||||||
|
if not ignore_errors and rc != expected_rc:
|
||||||
|
module.fail_json(
|
||||||
|
msg='Failed to run {command} {args}: {err}'.format(
|
||||||
|
command=command, args=args, err=err))
|
||||||
|
return rc, out, err
|
||||||
0
plugins/modules/__init__.py
Normal file
0
plugins/modules/__init__.py
Normal file
409
plugins/modules/podman_container_info.py
Normal file
409
plugins/modules/podman_container_info.py
Normal file
|
|
@ -0,0 +1,409 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2019 Ansible Project
|
||||||
|
# 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: podman_container_info
|
||||||
|
author:
|
||||||
|
- Sagi Shnaidman (@sshnaidm)
|
||||||
|
- Emilien Macchi (@EmilienM)
|
||||||
|
short_description: Gather facts about containers using podman
|
||||||
|
notes:
|
||||||
|
- Podman may require elevated privileges in order to run properly.
|
||||||
|
description:
|
||||||
|
- Gather facts about containers using C(podman)
|
||||||
|
requirements:
|
||||||
|
- "Podman installed on host"
|
||||||
|
options:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- List of container names to gather facts about. If no name is given
|
||||||
|
return facts about all containers.
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
executable:
|
||||||
|
description:
|
||||||
|
- Path to C(podman) executable if it is not in the C($PATH) on the
|
||||||
|
machine running C(podman)
|
||||||
|
default: 'podman'
|
||||||
|
type: str
|
||||||
|
'''
|
||||||
|
EXAMPLES = """
|
||||||
|
- name: Gather facts for all containers
|
||||||
|
podman_container_info:
|
||||||
|
|
||||||
|
- name: Gather facts on a specific container
|
||||||
|
podman_container_info:
|
||||||
|
name: web1
|
||||||
|
|
||||||
|
- name: Gather facts on several containers
|
||||||
|
podman_container_info:
|
||||||
|
name:
|
||||||
|
- redis
|
||||||
|
- web1
|
||||||
|
"""
|
||||||
|
RETURN = """
|
||||||
|
containers:
|
||||||
|
description: Facts from all or specificed containers
|
||||||
|
returned: always
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
sample: [
|
||||||
|
{
|
||||||
|
"Id": "c5c39f9b80a6ea2ad665aa9946435934e478a0c5322da835f3883872f",
|
||||||
|
"Created": "2019-10-01T12:51:00.233106443Z",
|
||||||
|
"Path": "dumb-init",
|
||||||
|
"Args": [
|
||||||
|
"--single-child",
|
||||||
|
"--",
|
||||||
|
"kolla_start"
|
||||||
|
],
|
||||||
|
"State": {
|
||||||
|
"OciVersion": "1.0.1-dev",
|
||||||
|
"Status": "configured",
|
||||||
|
"Running": false,
|
||||||
|
"Paused": false,
|
||||||
|
"Restarting": false,
|
||||||
|
"OOMKilled": false,
|
||||||
|
"Dead": false,
|
||||||
|
"Pid": 0,
|
||||||
|
"ExitCode": 0,
|
||||||
|
"Error": "",
|
||||||
|
"StartedAt": "0001-01-01T00:00:00Z",
|
||||||
|
"FinishedAt": "0001-01-01T00:00:00Z",
|
||||||
|
"Healthcheck": {
|
||||||
|
"Status": "",
|
||||||
|
"FailingStreak": 0,
|
||||||
|
"Log": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Image": "0e267acda67d0ebd643e900d820a91b961d859743039e620191ca1",
|
||||||
|
"ImageName": "docker.io/tripleomaster/centos-haproxy:latest",
|
||||||
|
"Rootfs": "",
|
||||||
|
"Pod": "",
|
||||||
|
"ResolvConfPath": "",
|
||||||
|
"HostnamePath": "",
|
||||||
|
"HostsPath": "",
|
||||||
|
"OCIRuntime": "runc",
|
||||||
|
"Name": "haproxy",
|
||||||
|
"RestartCount": 0,
|
||||||
|
"Driver": "overlay",
|
||||||
|
"MountLabel": "system_u:object_r:svirt_sandbox_file_t:s0:c78,c866",
|
||||||
|
"ProcessLabel": "system_u:system_r:svirt_lxc_net_t:s0:c785,c866",
|
||||||
|
"AppArmorProfile": "",
|
||||||
|
"EffectiveCaps": [
|
||||||
|
"CAP_CHOWN",
|
||||||
|
"CAP_DAC_OVERRIDE",
|
||||||
|
"CAP_FSETID",
|
||||||
|
"CAP_FOWNER",
|
||||||
|
"CAP_MKNOD",
|
||||||
|
"CAP_NET_RAW",
|
||||||
|
"CAP_SETGID",
|
||||||
|
"CAP_SETUID",
|
||||||
|
"CAP_SETFCAP",
|
||||||
|
"CAP_SETPCAP",
|
||||||
|
"CAP_NET_BIND_SERVICE",
|
||||||
|
"CAP_SYS_CHROOT",
|
||||||
|
"CAP_KILL",
|
||||||
|
"CAP_AUDIT_WRITE"
|
||||||
|
],
|
||||||
|
"BoundingCaps": [
|
||||||
|
"CAP_CHOWN",
|
||||||
|
"CAP_DAC_OVERRIDE",
|
||||||
|
"CAP_FSETID",
|
||||||
|
"CAP_FOWNER",
|
||||||
|
"CAP_MKNOD",
|
||||||
|
"CAP_NET_RAW",
|
||||||
|
"CAP_SETGID",
|
||||||
|
"CAP_SETUID",
|
||||||
|
"CAP_SETFCAP",
|
||||||
|
"CAP_SETPCAP",
|
||||||
|
"CAP_NET_BIND_SERVICE",
|
||||||
|
"CAP_SYS_CHROOT",
|
||||||
|
"CAP_KILL",
|
||||||
|
"CAP_AUDIT_WRITE"
|
||||||
|
],
|
||||||
|
"ExecIDs": [],
|
||||||
|
"GraphDriver": {
|
||||||
|
"Name": "overlay"
|
||||||
|
},
|
||||||
|
"Mounts": [],
|
||||||
|
"Dependencies": [],
|
||||||
|
"NetworkSettings": {
|
||||||
|
"Bridge": "",
|
||||||
|
"SandboxID": "",
|
||||||
|
"HairpinMode": false,
|
||||||
|
"LinkLocalIPv6Address": "",
|
||||||
|
"LinkLocalIPv6PrefixLen": 0,
|
||||||
|
"Ports": [],
|
||||||
|
"SandboxKey": "",
|
||||||
|
"SecondaryIPAddresses": null,
|
||||||
|
"SecondaryIPv6Addresses": null,
|
||||||
|
"EndpointID": "",
|
||||||
|
"Gateway": "",
|
||||||
|
"GlobalIPv6Address": "",
|
||||||
|
"GlobalIPv6PrefixLen": 0,
|
||||||
|
"IPAddress": "",
|
||||||
|
"IPPrefixLen": 0,
|
||||||
|
"IPv6Gateway": "",
|
||||||
|
"MacAddress": ""
|
||||||
|
},
|
||||||
|
"ExitCommand": [
|
||||||
|
"/usr/bin/podman",
|
||||||
|
"--root",
|
||||||
|
"/var/lib/containers/storage",
|
||||||
|
"--runroot",
|
||||||
|
"/var/run/containers/storage",
|
||||||
|
"--log-level",
|
||||||
|
"error",
|
||||||
|
"--cgroup-manager",
|
||||||
|
"systemd",
|
||||||
|
"--tmpdir",
|
||||||
|
"/var/run/libpod",
|
||||||
|
"--runtime",
|
||||||
|
"runc",
|
||||||
|
"--storage-driver",
|
||||||
|
"overlay",
|
||||||
|
"--events-backend",
|
||||||
|
"journald",
|
||||||
|
"container",
|
||||||
|
"cleanup",
|
||||||
|
"c9e813703f9b80a6ea2ad665aa9946435934e478a0c5322da835f3883872f"
|
||||||
|
],
|
||||||
|
"Namespace": "",
|
||||||
|
"IsInfra": false,
|
||||||
|
"Config": {
|
||||||
|
"Hostname": "c5c39e813703",
|
||||||
|
"Domainname": "",
|
||||||
|
"User": "",
|
||||||
|
"AttachStdin": false,
|
||||||
|
"AttachStdout": false,
|
||||||
|
"AttachStderr": false,
|
||||||
|
"Tty": false,
|
||||||
|
"OpenStdin": false,
|
||||||
|
"StdinOnce": false,
|
||||||
|
"Env": [
|
||||||
|
"PATH=/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
|
"TERM=xterm",
|
||||||
|
"HOSTNAME=",
|
||||||
|
"container=oci",
|
||||||
|
"KOLLA_INSTALL_METATYPE=rdo",
|
||||||
|
"KOLLA_BASE_DISTRO=centos",
|
||||||
|
"KOLLA_INSTALL_TYPE=binary",
|
||||||
|
"KOLLA_DISTRO_PYTHON_VERSION=2.7",
|
||||||
|
"KOLLA_BASE_ARCH=x86_64"
|
||||||
|
],
|
||||||
|
"Cmd": [
|
||||||
|
"kolla_start"
|
||||||
|
],
|
||||||
|
"Image": "docker.io/tripleomaster/centos-haproxy:latest",
|
||||||
|
"Volumes": null,
|
||||||
|
"WorkingDir": "/",
|
||||||
|
"Entrypoint": "dumb-init --single-child --",
|
||||||
|
"OnBuild": null,
|
||||||
|
"Labels": {
|
||||||
|
"build-date": "20190919",
|
||||||
|
"kolla_version": "8.1.0",
|
||||||
|
"name": "haproxy",
|
||||||
|
"org.label-schema.build-date": "20190801",
|
||||||
|
"org.label-schema.license": "GPLv2",
|
||||||
|
"org.label-schema.name": "CentOS Base Image",
|
||||||
|
"org.label-schema.schema-version": "1.0",
|
||||||
|
"org.label-schema.vendor": "CentOS"
|
||||||
|
},
|
||||||
|
"Annotations": {
|
||||||
|
"io.kubernetes.cri-o.ContainerType": "sandbox",
|
||||||
|
"io.kubernetes.cri-o.TTY": "false",
|
||||||
|
"io.podman.annotations.autoremove": "FALSE",
|
||||||
|
"io.podman.annotations.init": "FALSE",
|
||||||
|
"io.podman.annotations.privileged": "FALSE",
|
||||||
|
"io.podman.annotations.publish-all": "FALSE"
|
||||||
|
},
|
||||||
|
"StopSignal": 15
|
||||||
|
},
|
||||||
|
"HostConfig": {
|
||||||
|
"Binds": [],
|
||||||
|
"ContainerIDFile": "",
|
||||||
|
"LogConfig": {
|
||||||
|
"Type": "k8s-file",
|
||||||
|
"Config": null
|
||||||
|
},
|
||||||
|
"NetworkMode": "default",
|
||||||
|
"PortBindings": {},
|
||||||
|
"RestartPolicy": {
|
||||||
|
"Name": "",
|
||||||
|
"MaximumRetryCount": 0
|
||||||
|
},
|
||||||
|
"AutoRemove": false,
|
||||||
|
"VolumeDriver": "",
|
||||||
|
"VolumesFrom": null,
|
||||||
|
"CapAdd": [],
|
||||||
|
"CapDrop": [],
|
||||||
|
"Dns": [],
|
||||||
|
"DnsOptions": [],
|
||||||
|
"DnsSearch": [],
|
||||||
|
"ExtraHosts": [],
|
||||||
|
"GroupAdd": [],
|
||||||
|
"IpcMode": "",
|
||||||
|
"Cgroup": "",
|
||||||
|
"Links": null,
|
||||||
|
"OomScoreAdj": 0,
|
||||||
|
"PidMode": "",
|
||||||
|
"Privileged": false,
|
||||||
|
"PublishAllPorts": false,
|
||||||
|
"ReadonlyRootfs": false,
|
||||||
|
"SecurityOpt": [],
|
||||||
|
"Tmpfs": {},
|
||||||
|
"UTSMode": "",
|
||||||
|
"UsernsMode": "",
|
||||||
|
"ShmSize": 65536000,
|
||||||
|
"Runtime": "oci",
|
||||||
|
"ConsoleSize": [
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"Isolation": "",
|
||||||
|
"CpuShares": 0,
|
||||||
|
"Memory": 0,
|
||||||
|
"NanoCpus": 0,
|
||||||
|
"CgroupParent": "",
|
||||||
|
"BlkioWeight": 0,
|
||||||
|
"BlkioWeightDevice": null,
|
||||||
|
"BlkioDeviceReadBps": null,
|
||||||
|
"BlkioDeviceWriteBps": null,
|
||||||
|
"BlkioDeviceReadIOps": null,
|
||||||
|
"BlkioDeviceWriteIOps": null,
|
||||||
|
"CpuPeriod": 0,
|
||||||
|
"CpuQuota": 0,
|
||||||
|
"CpuRealtimePeriod": 0,
|
||||||
|
"CpuRealtimeRuntime": 0,
|
||||||
|
"CpusetCpus": "",
|
||||||
|
"CpusetMems": "",
|
||||||
|
"Devices": [],
|
||||||
|
"DiskQuota": 0,
|
||||||
|
"KernelMemory": 0,
|
||||||
|
"MemoryReservation": 0,
|
||||||
|
"MemorySwap": 0,
|
||||||
|
"MemorySwappiness": -1,
|
||||||
|
"OomKillDisable": false,
|
||||||
|
"PidsLimit": 0,
|
||||||
|
"Ulimits": [
|
||||||
|
{
|
||||||
|
"Name": "RLIMIT_NOFILE",
|
||||||
|
"Soft": 1048576,
|
||||||
|
"Hard": 1048576
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "RLIMIT_NPROC",
|
||||||
|
"Soft": 1048576,
|
||||||
|
"Hard": 1048576
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"CpuCount": 0,
|
||||||
|
"CpuPercent": 0,
|
||||||
|
"IOMaximumIOps": 0,
|
||||||
|
"IOMaximumBandwidth": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
def get_containers_facts(module, executable, name):
|
||||||
|
"""Collect containers facts for all containers or for specified in 'name'.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
module {AnsibleModule} -- instance of AnsibleModule
|
||||||
|
executable {string} -- binary to execute when inspecting containers
|
||||||
|
name {list} -- list of names or None in case of all containers
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list of containers info, stdout, stderr
|
||||||
|
"""
|
||||||
|
if not name:
|
||||||
|
all_names = [executable, 'container', 'ls', '-q', '-a']
|
||||||
|
rc, out, err = module.run_command(all_names)
|
||||||
|
if rc != 0:
|
||||||
|
module.fail_json(msg="Unable to get list of containers: %s" % err)
|
||||||
|
name = out.split()
|
||||||
|
if not name:
|
||||||
|
return [], out, err
|
||||||
|
command = [executable, 'container', 'inspect']
|
||||||
|
command.extend(name)
|
||||||
|
rc, out, err = module.run_command(command)
|
||||||
|
if rc == 0:
|
||||||
|
json_out = json.loads(out) if out else None
|
||||||
|
if json_out is None:
|
||||||
|
return [], out, err
|
||||||
|
return json_out, out, err
|
||||||
|
if rc != 0 and 'no such ' in err:
|
||||||
|
if len(name) < 2:
|
||||||
|
return [], out, err
|
||||||
|
return cycle_over(module, executable, name)
|
||||||
|
module.fail_json(msg="Unable to gather info for %s: %s" % (",".join(name), err))
|
||||||
|
|
||||||
|
|
||||||
|
def cycle_over(module, executable, name):
|
||||||
|
"""Inspect each container in a cycle in case some of them don't exist.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
module {AnsibleModule} -- instance of AnsibleModule
|
||||||
|
executable {string} -- binary to execute when inspecting containers
|
||||||
|
name {list} -- list of containers names to inspect
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list of containers info, stdout as empty, stderr
|
||||||
|
"""
|
||||||
|
inspection = []
|
||||||
|
stderrs = []
|
||||||
|
for container in name:
|
||||||
|
command = [executable, 'container', 'inspect', container]
|
||||||
|
rc, out, err = module.run_command(command)
|
||||||
|
if rc != 0 and 'no such ' not in err:
|
||||||
|
module.fail_json(msg="Unable to gather info for %s: %s" % (container, err))
|
||||||
|
if rc == 0 and out:
|
||||||
|
json_out = json.loads(out)
|
||||||
|
if json_out:
|
||||||
|
inspection += json_out
|
||||||
|
stderrs.append(err)
|
||||||
|
return inspection, "", "\n".join(stderrs)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec={
|
||||||
|
'executable': {'type': 'str', 'default': 'podman'},
|
||||||
|
'name': {'type': 'list', 'elements': 'str'},
|
||||||
|
},
|
||||||
|
supports_check_mode=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
name = module.params['name']
|
||||||
|
executable = module.get_bin_path(module.params['executable'], required=True)
|
||||||
|
|
||||||
|
inspect_results, out, err = get_containers_facts(module, executable, name)
|
||||||
|
|
||||||
|
results = {
|
||||||
|
"changed": False,
|
||||||
|
"containers": inspect_results,
|
||||||
|
"stderr": err
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exit_json(**results)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
728
plugins/modules/podman_image.py
Normal file
728
plugins/modules/podman_image.py
Normal file
|
|
@ -0,0 +1,728 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2018 Ansible Project
|
||||||
|
# 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: podman_image
|
||||||
|
author:
|
||||||
|
- Sam Doran (@samdoran)
|
||||||
|
short_description: Pull images for use by podman
|
||||||
|
notes: []
|
||||||
|
description:
|
||||||
|
- Build, pull, or push images using Podman.
|
||||||
|
options:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Name of the image to pull, push, or delete. It may contain a tag using the format C(image:tag).
|
||||||
|
required: True
|
||||||
|
executable:
|
||||||
|
description:
|
||||||
|
- Path to C(podman) executable if it is not in the C($PATH) on the machine running C(podman)
|
||||||
|
default: 'podman'
|
||||||
|
type: str
|
||||||
|
ca_cert_dir:
|
||||||
|
description:
|
||||||
|
- Path to directory containing TLS certificates and keys to use
|
||||||
|
type: 'path'
|
||||||
|
tag:
|
||||||
|
description:
|
||||||
|
- Tag of the image to pull, push, or delete.
|
||||||
|
default: "latest"
|
||||||
|
pull:
|
||||||
|
description: Whether or not to pull the image.
|
||||||
|
default: True
|
||||||
|
push:
|
||||||
|
description: Whether or not to push an image.
|
||||||
|
default: False
|
||||||
|
path:
|
||||||
|
description: Path to directory containing the build file.
|
||||||
|
force:
|
||||||
|
description:
|
||||||
|
- Whether or not to force push or pull an image. When building, force the build even if the image already exists.
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- Whether an image should be present, absent, or built.
|
||||||
|
default: "present"
|
||||||
|
choices:
|
||||||
|
- present
|
||||||
|
- absent
|
||||||
|
- build
|
||||||
|
validate_certs:
|
||||||
|
description:
|
||||||
|
- Require HTTPS and validate certificates when pulling or pushing. Also used during build if a pull or push is necessary.
|
||||||
|
default: True
|
||||||
|
aliases:
|
||||||
|
- tlsverify
|
||||||
|
- tls_verify
|
||||||
|
password:
|
||||||
|
description:
|
||||||
|
- Password to use when authenticating to remote registries.
|
||||||
|
type: str
|
||||||
|
username:
|
||||||
|
description:
|
||||||
|
- username to use when authenticating to remote registries.
|
||||||
|
type: str
|
||||||
|
auth_file:
|
||||||
|
description:
|
||||||
|
- Path to file containing authorization credentials to the remote registry
|
||||||
|
aliases:
|
||||||
|
- authfile
|
||||||
|
build:
|
||||||
|
description: Arguments that control image build.
|
||||||
|
aliases:
|
||||||
|
- build_args
|
||||||
|
- buildargs
|
||||||
|
suboptions:
|
||||||
|
annotation:
|
||||||
|
description:
|
||||||
|
- Dictionary of key=value pairs to add to the image. Only works with OCI images. Ignored for Docker containers.
|
||||||
|
type: str
|
||||||
|
force_rm:
|
||||||
|
description:
|
||||||
|
- Always remove intermediate containers after a build, even if the build is unsuccessful.
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
format:
|
||||||
|
description:
|
||||||
|
- Format of the built image.
|
||||||
|
choices:
|
||||||
|
- docker
|
||||||
|
- oci
|
||||||
|
default: "oci"
|
||||||
|
cache:
|
||||||
|
description:
|
||||||
|
- Whether or not to use cached layers when building an image
|
||||||
|
type: bool
|
||||||
|
default: True
|
||||||
|
rm:
|
||||||
|
description: Remove intermediate containers after a successful build
|
||||||
|
type: bool
|
||||||
|
default: True
|
||||||
|
push_args:
|
||||||
|
description: Arguments that control pushing images.
|
||||||
|
suboptions:
|
||||||
|
compress:
|
||||||
|
description:
|
||||||
|
- Compress tarball image layers when pushing to a directory using the 'dir' transport.
|
||||||
|
type: bool
|
||||||
|
format:
|
||||||
|
description:
|
||||||
|
- Manifest type to use when pushing an image using the 'dir' transport (default is manifest type of source)
|
||||||
|
choices:
|
||||||
|
- oci
|
||||||
|
- v2s1
|
||||||
|
- v2s2
|
||||||
|
remove_signatures:
|
||||||
|
description: Discard any pre-existing signatures in the image
|
||||||
|
type: bool
|
||||||
|
sign_by:
|
||||||
|
description:
|
||||||
|
- Path to a key file to use to sign the image.
|
||||||
|
dest:
|
||||||
|
description: Path or URL where image will be pushed.
|
||||||
|
transport:
|
||||||
|
description:
|
||||||
|
- Transport to use when pushing in image. If no transport is set, will attempt to push to a remote registry.
|
||||||
|
choices:
|
||||||
|
- dir
|
||||||
|
- docker-archive
|
||||||
|
- docker-daemon
|
||||||
|
- oci-archive
|
||||||
|
- ostree
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = """
|
||||||
|
- name: Pull an image
|
||||||
|
podman_image:
|
||||||
|
name: quay.io/bitnami/wildfly
|
||||||
|
|
||||||
|
- name: Remove an image
|
||||||
|
podman_image:
|
||||||
|
name: quay.io/bitnami/wildfly
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Pull a specific version of an image
|
||||||
|
podman_image:
|
||||||
|
name: redis
|
||||||
|
tag: 4
|
||||||
|
|
||||||
|
- name: Build a basic OCI image
|
||||||
|
podman_image:
|
||||||
|
name: nginx
|
||||||
|
path: /path/to/build/dir
|
||||||
|
|
||||||
|
- name: Build a basic OCI image with advanced parameters
|
||||||
|
podman_image:
|
||||||
|
name: nginx
|
||||||
|
path: /path/to/build/dir
|
||||||
|
build:
|
||||||
|
cache: no
|
||||||
|
force_rm: yes
|
||||||
|
format: oci
|
||||||
|
annotation:
|
||||||
|
app: nginx
|
||||||
|
function: proxy
|
||||||
|
info: Load balancer for my cool app
|
||||||
|
|
||||||
|
- name: Build a Docker formatted image
|
||||||
|
podman_image:
|
||||||
|
name: nginx
|
||||||
|
path: /path/to/build/dir
|
||||||
|
build:
|
||||||
|
format: docker
|
||||||
|
|
||||||
|
- name: Build and push an image using existing credentials
|
||||||
|
podman_image:
|
||||||
|
name: nginx
|
||||||
|
path: /path/to/build/dir
|
||||||
|
push: yes
|
||||||
|
push_args:
|
||||||
|
dest: quay.io/acme
|
||||||
|
|
||||||
|
- name: Build and push an image using an auth file
|
||||||
|
podman_image:
|
||||||
|
name: nginx
|
||||||
|
push: yes
|
||||||
|
auth_file: /etc/containers/auth.json
|
||||||
|
push_args:
|
||||||
|
dest: quay.io/acme
|
||||||
|
|
||||||
|
- name: Build and push an image using username and password
|
||||||
|
podman_image:
|
||||||
|
name: nginx
|
||||||
|
push: yes
|
||||||
|
username: bugs
|
||||||
|
password: "{{ vault_registry_password }}"
|
||||||
|
push_args:
|
||||||
|
dest: quay.io/acme
|
||||||
|
|
||||||
|
- name: Build and push an image to multiple registries
|
||||||
|
podman_image:
|
||||||
|
name: "{{ item }}"
|
||||||
|
path: /path/to/build/dir
|
||||||
|
push: yes
|
||||||
|
auth_file: /etc/containers/auth.json
|
||||||
|
loop:
|
||||||
|
- quay.io/acme/nginx
|
||||||
|
- docker.io/acme/nginx
|
||||||
|
|
||||||
|
- name: Build and push an image to multiple registries with separate parameters
|
||||||
|
podman_image:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
tag: "{{ item.tag }}"
|
||||||
|
path: /path/to/build/dir
|
||||||
|
push: yes
|
||||||
|
auth_file: /etc/containers/auth.json
|
||||||
|
push_args:
|
||||||
|
dest: "{{ item.dest }}"
|
||||||
|
loop:
|
||||||
|
- name: nginx
|
||||||
|
tag: 4
|
||||||
|
dest: docker.io/acme
|
||||||
|
|
||||||
|
- name: nginx
|
||||||
|
tag: 3
|
||||||
|
dest: docker.io/acme
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
image:
|
||||||
|
description:
|
||||||
|
- Image inspection results for the image that was pulled, pushed, or built.
|
||||||
|
returned: success
|
||||||
|
type: dict
|
||||||
|
sample: [
|
||||||
|
{
|
||||||
|
"Annotations": {},
|
||||||
|
"Architecture": "amd64",
|
||||||
|
"Author": "",
|
||||||
|
"Comment": "from Bitnami with love",
|
||||||
|
"ContainerConfig": {
|
||||||
|
"Cmd": [
|
||||||
|
"/run.sh"
|
||||||
|
],
|
||||||
|
"Entrypoint": [
|
||||||
|
"/app-entrypoint.sh"
|
||||||
|
],
|
||||||
|
"Env": [
|
||||||
|
"PATH=/opt/bitnami/java/bin:/opt/bitnami/wildfly/bin:/opt/bitnami/nami/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
|
"IMAGE_OS=debian-9",
|
||||||
|
"NAMI_VERSION=1.0.0-1",
|
||||||
|
"GPG_KEY_SERVERS_LIST=ha.pool.sks-keyservers.net",
|
||||||
|
"TINI_VERSION=v0.13.2",
|
||||||
|
"TINI_GPG_KEY=595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7",
|
||||||
|
"GOSU_VERSION=1.10",
|
||||||
|
"GOSU_GPG_KEY=B42F6819007F00F88E364FD4036A9C25BF357DD4",
|
||||||
|
"BITNAMI_IMAGE_VERSION=16.0.0-debian-9-r27",
|
||||||
|
"BITNAMI_PKG_CHMOD=-R g+rwX",
|
||||||
|
"BITNAMI_PKG_EXTRA_DIRS=/home/wildfly",
|
||||||
|
"HOME=/",
|
||||||
|
"BITNAMI_APP_NAME=wildfly",
|
||||||
|
"NAMI_PREFIX=/.nami",
|
||||||
|
"WILDFLY_HOME=/home/wildfly",
|
||||||
|
"WILDFLY_JAVA_HOME=",
|
||||||
|
"WILDFLY_JAVA_OPTS=",
|
||||||
|
"WILDFLY_MANAGEMENT_HTTP_PORT_NUMBER=9990",
|
||||||
|
"WILDFLY_PASSWORD=bitnami",
|
||||||
|
"WILDFLY_PUBLIC_CONSOLE=true",
|
||||||
|
"WILDFLY_SERVER_AJP_PORT_NUMBER=8009",
|
||||||
|
"WILDFLY_SERVER_HTTP_PORT_NUMBER=8080",
|
||||||
|
"WILDFLY_SERVER_INTERFACE=0.0.0.0",
|
||||||
|
"WILDFLY_USERNAME=user",
|
||||||
|
"WILDFLY_WILDFLY_HOME=/home/wildfly",
|
||||||
|
"WILDFLY_WILDFLY_OPTS=-Dwildfly.as.deployment.ondemand=false"
|
||||||
|
],
|
||||||
|
"ExposedPorts": {
|
||||||
|
"8080/tcp": {},
|
||||||
|
"9990/tcp": {}
|
||||||
|
},
|
||||||
|
"Labels": {
|
||||||
|
"maintainer": "Bitnami <containers@bitnami.com>"
|
||||||
|
},
|
||||||
|
"User": "1001"
|
||||||
|
},
|
||||||
|
"Created": "2019-04-10T05:48:03.553887623Z",
|
||||||
|
"Digest": "sha256:5a8ab28e314c2222de3feaf6dac94a0436a37fc08979d2722c99d2bef2619a9b",
|
||||||
|
"GraphDriver": {
|
||||||
|
"Data": {
|
||||||
|
"LowerDir": "/var/lib/containers/storage/overlay/142c1beadf1bb09fbd929465ec98c9dca3256638220450efb4214727d0d0680e/diff:/var/lib/containers/s",
|
||||||
|
"MergedDir": "/var/lib/containers/storage/overlay/9aa10191f5bddb59e28508e721fdeb43505e5b395845fa99723ed787878dbfea/merged",
|
||||||
|
"UpperDir": "/var/lib/containers/storage/overlay/9aa10191f5bddb59e28508e721fdeb43505e5b395845fa99723ed787878dbfea/diff",
|
||||||
|
"WorkDir": "/var/lib/containers/storage/overlay/9aa10191f5bddb59e28508e721fdeb43505e5b395845fa99723ed787878dbfea/work"
|
||||||
|
},
|
||||||
|
"Name": "overlay"
|
||||||
|
},
|
||||||
|
"History": [
|
||||||
|
{
|
||||||
|
"comment": "from Bitnami with love",
|
||||||
|
"created": "2019-04-09T22:27:40.659377677Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"created": "2019-04-09T22:38:53.86336555Z",
|
||||||
|
"created_by": "/bin/sh -c #(nop) LABEL maintainer=Bitnami <containers@bitnami.com>",
|
||||||
|
"empty_layer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"created": "2019-04-09T22:38:54.022778765Z",
|
||||||
|
"created_by": "/bin/sh -c #(nop) ENV IMAGE_OS=debian-9",
|
||||||
|
"empty_layer": true
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"Id": "ace34da54e4af2145e1ad277005adb235a214e4dfe1114c2db9ab460b840f785",
|
||||||
|
"Labels": {
|
||||||
|
"maintainer": "Bitnami <containers@bitnami.com>"
|
||||||
|
},
|
||||||
|
"ManifestType": "application/vnd.docker.distribution.manifest.v1+prettyjws",
|
||||||
|
"Os": "linux",
|
||||||
|
"Parent": "",
|
||||||
|
"RepoDigests": [
|
||||||
|
"quay.io/bitnami/wildfly@sha256:5a8ab28e314c2222de3feaf6dac94a0436a37fc08979d2722c99d2bef2619a9b"
|
||||||
|
],
|
||||||
|
"RepoTags": [
|
||||||
|
"quay.io/bitnami/wildfly:latest"
|
||||||
|
],
|
||||||
|
"RootFS": {
|
||||||
|
"Layers": [
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"Type": "layers"
|
||||||
|
},
|
||||||
|
"Size": 466180019,
|
||||||
|
"User": "1001",
|
||||||
|
"Version": "18.09.3",
|
||||||
|
"VirtualSize": 466180019
|
||||||
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible_collections.containers.podman.plugins.module_utils.podman.common import run_podman_command
|
||||||
|
|
||||||
|
|
||||||
|
class PodmanImageManager(object):
|
||||||
|
|
||||||
|
def __init__(self, module, results):
|
||||||
|
|
||||||
|
super(PodmanImageManager, self).__init__()
|
||||||
|
|
||||||
|
self.module = module
|
||||||
|
self.results = results
|
||||||
|
self.name = self.module.params.get('name')
|
||||||
|
self.executable = self.module.get_bin_path(module.params.get('executable'), required=True)
|
||||||
|
self.tag = self.module.params.get('tag')
|
||||||
|
self.pull = self.module.params.get('pull')
|
||||||
|
self.push = self.module.params.get('push')
|
||||||
|
self.path = self.module.params.get('path')
|
||||||
|
self.force = self.module.params.get('force')
|
||||||
|
self.state = self.module.params.get('state')
|
||||||
|
self.validate_certs = self.module.params.get('validate_certs')
|
||||||
|
self.auth_file = self.module.params.get('auth_file')
|
||||||
|
self.username = self.module.params.get('username')
|
||||||
|
self.password = self.module.params.get('password')
|
||||||
|
self.ca_cert_dir = self.module.params.get('ca_cert_dir')
|
||||||
|
self.build = self.module.params.get('build')
|
||||||
|
self.push_args = self.module.params.get('push_args')
|
||||||
|
|
||||||
|
repo, repo_tag = parse_repository_tag(self.name)
|
||||||
|
if repo_tag:
|
||||||
|
self.name = repo
|
||||||
|
self.tag = repo_tag
|
||||||
|
|
||||||
|
self.image_name = '{name}:{tag}'.format(name=self.name, tag=self.tag)
|
||||||
|
|
||||||
|
if self.state in ['present', 'build']:
|
||||||
|
self.present()
|
||||||
|
|
||||||
|
if self.state in ['absent']:
|
||||||
|
self.absent()
|
||||||
|
|
||||||
|
def _run(self, args, expected_rc=0, ignore_errors=False):
|
||||||
|
return run_podman_command(
|
||||||
|
module=self.module,
|
||||||
|
executable=self.executable,
|
||||||
|
args=args,
|
||||||
|
expected_rc=expected_rc,
|
||||||
|
ignore_errors=ignore_errors)
|
||||||
|
|
||||||
|
def _get_id_from_output(self, lines, startswith=None, contains=None, split_on=' ', maxsplit=1):
|
||||||
|
layer_ids = []
|
||||||
|
for line in lines.splitlines():
|
||||||
|
if startswith and line.startswith(startswith) or contains and contains in line:
|
||||||
|
splitline = line.rsplit(split_on, maxsplit)
|
||||||
|
layer_ids.append(splitline[1])
|
||||||
|
|
||||||
|
# Podman 1.4 changed the output to only include the layer id when run in quiet mode
|
||||||
|
if not layer_ids:
|
||||||
|
layer_ids = lines.splitlines()
|
||||||
|
|
||||||
|
return(layer_ids[-1])
|
||||||
|
|
||||||
|
def present(self):
|
||||||
|
image = self.find_image()
|
||||||
|
|
||||||
|
if not image or self.force:
|
||||||
|
if self.path:
|
||||||
|
# Build the image
|
||||||
|
self.results['actions'].append('Built image {image_name} from {path}'.format(image_name=self.image_name, path=self.path))
|
||||||
|
self.results['changed'] = True
|
||||||
|
if not self.module.check_mode:
|
||||||
|
self.results['image'] = self.build_image()
|
||||||
|
else:
|
||||||
|
# Pull the image
|
||||||
|
self.results['actions'].append('Pulled image {image_name}'.format(image_name=self.image_name))
|
||||||
|
self.results['changed'] = True
|
||||||
|
if not self.module.check_mode:
|
||||||
|
self.results['image'] = self.pull_image()
|
||||||
|
|
||||||
|
if self.push:
|
||||||
|
# Push the image
|
||||||
|
if '/' in self.image_name:
|
||||||
|
push_format_string = 'Pushed image {image_name}'
|
||||||
|
else:
|
||||||
|
push_format_string = 'Pushed image {image_name} to {dest}'
|
||||||
|
self.results['actions'].append(push_format_string.format(image_name=self.image_name, dest=self.push_args['dest']))
|
||||||
|
self.results['changed'] = True
|
||||||
|
if not self.module.check_mode:
|
||||||
|
self.results['image'] = self.push_image()
|
||||||
|
|
||||||
|
def absent(self):
|
||||||
|
image = self.find_image()
|
||||||
|
|
||||||
|
if image:
|
||||||
|
self.results['actions'].append('Removed image {name}'.format(name=self.name))
|
||||||
|
self.results['changed'] = True
|
||||||
|
self.results['image']['state'] = 'Deleted'
|
||||||
|
if not self.module.check_mode:
|
||||||
|
self.remove_image()
|
||||||
|
|
||||||
|
def find_image(self, image_name=None):
|
||||||
|
if image_name is None:
|
||||||
|
image_name = self.image_name
|
||||||
|
args = ['image', 'ls', image_name, '--format', 'json']
|
||||||
|
rc, images, err = self._run(args, ignore_errors=True)
|
||||||
|
if len(images) > 0:
|
||||||
|
return json.loads(images)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def inspect_image(self, image_name=None):
|
||||||
|
if image_name is None:
|
||||||
|
image_name = self.image_name
|
||||||
|
args = ['inspect', image_name, '--format', 'json']
|
||||||
|
rc, image_data, err = self._run(args)
|
||||||
|
if len(image_data) > 0:
|
||||||
|
return json.loads(image_data)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def pull_image(self, image_name=None):
|
||||||
|
if image_name is None:
|
||||||
|
image_name = self.image_name
|
||||||
|
|
||||||
|
args = ['pull', image_name, '-q']
|
||||||
|
|
||||||
|
if self.auth_file:
|
||||||
|
args.extend(['--authfile', self.auth_file])
|
||||||
|
|
||||||
|
if self.username and self.password:
|
||||||
|
cred_string = '{user}:{password}'.format(user=self.username, password=self.password)
|
||||||
|
args.extend(['--creds', cred_string])
|
||||||
|
|
||||||
|
if self.validate_certs:
|
||||||
|
args.append('--tls-verify')
|
||||||
|
|
||||||
|
if self.ca_cert_dir:
|
||||||
|
args.extend(['--cert-dir', self.ca_cert_dir])
|
||||||
|
|
||||||
|
rc, out, err = self._run(args, ignore_errors=True)
|
||||||
|
if rc != 0:
|
||||||
|
self.module.fail_json(msg='Failed to pull image {image_name}'.format(image_name=image_name))
|
||||||
|
return self.inspect_image(out.strip())
|
||||||
|
|
||||||
|
def build_image(self):
|
||||||
|
args = ['build', '-q']
|
||||||
|
args.extend(['-t', self.image_name])
|
||||||
|
|
||||||
|
if self.validate_certs:
|
||||||
|
args.append('--tls-verify')
|
||||||
|
|
||||||
|
annotation = self.build.get('annotation')
|
||||||
|
if annotation:
|
||||||
|
for k, v in annotation.items():
|
||||||
|
args.extend(['--annotation', '{k}={v}'.format(k=k, v=v)])
|
||||||
|
|
||||||
|
if self.ca_cert_dir:
|
||||||
|
args.extend(['--cert-dir', self.ca_cert_dir])
|
||||||
|
|
||||||
|
if self.build.get('force_rm'):
|
||||||
|
args.append('--force-rm')
|
||||||
|
|
||||||
|
image_format = self.build.get('format')
|
||||||
|
if image_format:
|
||||||
|
args.extend(['--format', image_format])
|
||||||
|
|
||||||
|
if not self.build.get('cache'):
|
||||||
|
args.append('--no-cache')
|
||||||
|
|
||||||
|
if self.build.get('rm'):
|
||||||
|
args.append('--rm')
|
||||||
|
|
||||||
|
volume = self.build.get('volume')
|
||||||
|
if volume:
|
||||||
|
for v in volume:
|
||||||
|
args.extend(['--volume', v])
|
||||||
|
|
||||||
|
if self.auth_file:
|
||||||
|
args.extend(['--authfile', self.auth_file])
|
||||||
|
|
||||||
|
if self.username and self.password:
|
||||||
|
cred_string = '{user}:{password}'.format(user=self.username, password=self.password)
|
||||||
|
args.extend(['--creds', cred_string])
|
||||||
|
|
||||||
|
args.append(self.path)
|
||||||
|
|
||||||
|
rc, out, err = self._run(args, ignore_errors=True)
|
||||||
|
if rc != 0:
|
||||||
|
self.module.fail_json(msg="Failed to build image {image}: {out} {err}".format(image=self.image_name, out=out, err=err))
|
||||||
|
|
||||||
|
last_id = self._get_id_from_output(out, startswith='-->')
|
||||||
|
return self.inspect_image(last_id)
|
||||||
|
|
||||||
|
def push_image(self):
|
||||||
|
args = ['push']
|
||||||
|
|
||||||
|
if self.validate_certs:
|
||||||
|
args.append('--tls-verify')
|
||||||
|
|
||||||
|
if self.ca_cert_dir:
|
||||||
|
args.extend(['--cert-dir', self.ca_cert_dir])
|
||||||
|
|
||||||
|
if self.username and self.password:
|
||||||
|
cred_string = '{user}:{password}'.format(user=self.username, password=self.password)
|
||||||
|
args.extend(['--creds', cred_string])
|
||||||
|
|
||||||
|
if self.auth_file:
|
||||||
|
args.extend(['--authfile', self.auth_file])
|
||||||
|
|
||||||
|
if self.push_args.get('compress'):
|
||||||
|
args.append('--compress')
|
||||||
|
|
||||||
|
push_format = self.push_args.get('format')
|
||||||
|
if push_format:
|
||||||
|
args.extend(['--format', push_format])
|
||||||
|
|
||||||
|
if self.push_args.get('remove_signatures'):
|
||||||
|
args.append('--remove_signatures')
|
||||||
|
|
||||||
|
sign_by_key = self.push_args.get('sign_by')
|
||||||
|
if sign_by_key:
|
||||||
|
args.extend(['--sign-by', sign_by_key])
|
||||||
|
|
||||||
|
args.append(self.image_name)
|
||||||
|
|
||||||
|
# Build the destination argument
|
||||||
|
dest = self.push_args.get('dest')
|
||||||
|
dest_format_string = '{dest}/{image_name}'
|
||||||
|
regexp = re.compile(r'/{name}(:{tag})?'.format(name=self.name, tag=self.tag))
|
||||||
|
if not dest:
|
||||||
|
if '/' not in self.name:
|
||||||
|
self.module.fail_json(msg="'push_args['dest']' is required when pushing images that do not have the remote registry in the image name")
|
||||||
|
|
||||||
|
# If the push destination contains the image name and/or the tag
|
||||||
|
# remove it and warn since it's not needed.
|
||||||
|
elif regexp.search(dest):
|
||||||
|
dest = regexp.sub('', dest)
|
||||||
|
self.module.warn("Image name and tag are automatically added to push_args['dest']. Destination changed to {dest}".format(dest=dest))
|
||||||
|
|
||||||
|
if dest and dest.endswith('/'):
|
||||||
|
dest = dest[:-1]
|
||||||
|
|
||||||
|
transport = self.push_args.get('transport')
|
||||||
|
if transport:
|
||||||
|
if not dest:
|
||||||
|
self.module.fail_json("'push_args['transport'] requires 'push_args['dest'] but it was not provided.")
|
||||||
|
if transport == 'docker':
|
||||||
|
dest_format_string = '{transport}://{dest}'
|
||||||
|
elif transport == 'ostree':
|
||||||
|
dest_format_string = '{transport}:{name}@{dest}'
|
||||||
|
else:
|
||||||
|
dest_format_string = '{transport}:{dest}'
|
||||||
|
|
||||||
|
dest_string = dest_format_string.format(transport=transport, name=self.name, dest=dest, image_name=self.image_name,)
|
||||||
|
|
||||||
|
# Only append the destination argument if the image name is not a URL
|
||||||
|
if '/' not in self.name:
|
||||||
|
args.append(dest_string)
|
||||||
|
|
||||||
|
rc, out, err = self._run(args, ignore_errors=True)
|
||||||
|
if rc != 0:
|
||||||
|
self.module.fail_json(msg="Failed to push image {image_name}: {err}".format(image_name=self.image_name, err=err))
|
||||||
|
last_id = self._get_id_from_output(
|
||||||
|
out + err, contains=':', split_on=':')
|
||||||
|
|
||||||
|
return self.inspect_image(last_id)
|
||||||
|
|
||||||
|
def remove_image(self, image_name=None):
|
||||||
|
if image_name is None:
|
||||||
|
image_name = self.image_name
|
||||||
|
|
||||||
|
args = ['rmi', image_name]
|
||||||
|
if self.force:
|
||||||
|
args.append('--force')
|
||||||
|
rc, out, err = self._run(args, ignore_errors=True)
|
||||||
|
if rc != 0:
|
||||||
|
self.module.fail_json(msg='Failed to remove image {image_name}. {err}'.format(image_name=image_name, err=err))
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def parse_repository_tag(repo_name):
|
||||||
|
parts = repo_name.rsplit('@', 1)
|
||||||
|
if len(parts) == 2:
|
||||||
|
return tuple(parts)
|
||||||
|
parts = repo_name.rsplit(':', 1)
|
||||||
|
if len(parts) == 2 and '/' not in parts[1]:
|
||||||
|
return tuple(parts)
|
||||||
|
return repo_name, None
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(
|
||||||
|
name=dict(type='str', required=True),
|
||||||
|
tag=dict(type='str', default='latest'),
|
||||||
|
pull=dict(type='bool', default=True),
|
||||||
|
push=dict(type='bool', default=False),
|
||||||
|
path=dict(type='str'),
|
||||||
|
force=dict(type='bool', default=False),
|
||||||
|
state=dict(type='str', default='present', choices=['absent', 'present', 'build']),
|
||||||
|
validate_certs=dict(type='bool', default=True, aliases=['tlsverify', 'tls_verify']),
|
||||||
|
executable=dict(type='str', default='podman'),
|
||||||
|
auth_file=dict(type='path', aliases=['authfile']),
|
||||||
|
username=dict(type='str'),
|
||||||
|
password=dict(type='str', no_log=True),
|
||||||
|
ca_cert_dir=dict(type='path'),
|
||||||
|
build=dict(
|
||||||
|
type='dict',
|
||||||
|
aliases=['build_args', 'buildargs'],
|
||||||
|
default={},
|
||||||
|
options=dict(
|
||||||
|
annotation=dict(type='dict'),
|
||||||
|
force_rm=dict(type='bool'),
|
||||||
|
format=dict(
|
||||||
|
type='str',
|
||||||
|
choices=['oci', 'docker'],
|
||||||
|
default='oci'
|
||||||
|
),
|
||||||
|
cache=dict(type='bool', default=True),
|
||||||
|
rm=dict(type='bool', default=True),
|
||||||
|
volume=dict(type='list'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
push_args=dict(
|
||||||
|
type='dict',
|
||||||
|
default={},
|
||||||
|
options=dict(
|
||||||
|
compress=dict(type='bool'),
|
||||||
|
format=dict(type='str', choices=['oci', 'v2s1', 'v2s2']),
|
||||||
|
remove_signatures=dict(type='bool'),
|
||||||
|
sign_by=dict(type='str'),
|
||||||
|
dest=dict(type='str', aliases=['destination'],),
|
||||||
|
transport=dict(
|
||||||
|
type='str',
|
||||||
|
choices=[
|
||||||
|
'dir',
|
||||||
|
'docker-archive',
|
||||||
|
'docker-daemon',
|
||||||
|
'oci-archive',
|
||||||
|
'ostree',
|
||||||
|
]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
supports_check_mode=True,
|
||||||
|
required_together=(
|
||||||
|
['username', 'password'],
|
||||||
|
),
|
||||||
|
mutually_exclusive=(
|
||||||
|
['authfile', 'username'],
|
||||||
|
['authfile', 'password'],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
results = dict(
|
||||||
|
changed=False,
|
||||||
|
actions=[],
|
||||||
|
image={},
|
||||||
|
)
|
||||||
|
|
||||||
|
PodmanImageManager(module, results)
|
||||||
|
module.exit_json(**results)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
238
plugins/modules/podman_image_info.py
Normal file
238
plugins/modules/podman_image_info.py
Normal file
|
|
@ -0,0 +1,238 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2018 Ansible Project
|
||||||
|
# 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: podman_image_info
|
||||||
|
author:
|
||||||
|
- Sam Doran (@samdoran)
|
||||||
|
short_description: Gather info about images using podman
|
||||||
|
notes:
|
||||||
|
- Podman may required elevated privileges in order to run properly.
|
||||||
|
description:
|
||||||
|
- Gather info about images using C(podman)
|
||||||
|
options:
|
||||||
|
executable:
|
||||||
|
description:
|
||||||
|
- Path to C(podman) executable if it is not in the C($PATH) on the machine running C(podman)
|
||||||
|
default: 'podman'
|
||||||
|
type: str
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- List of tags or UID to gather info about. If no name is given return info about all images.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = """
|
||||||
|
- name: Gather info for all images
|
||||||
|
podman_image_info:
|
||||||
|
|
||||||
|
- name: Gather info on a specific image
|
||||||
|
podman_image_info:
|
||||||
|
name: nginx
|
||||||
|
|
||||||
|
- name: Gather info on several images
|
||||||
|
podman_image_info:
|
||||||
|
name:
|
||||||
|
- redis
|
||||||
|
- quay.io/bitnami/wildfly
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
images:
|
||||||
|
description: info from all or specified images
|
||||||
|
returned: always
|
||||||
|
type: dict
|
||||||
|
sample: [
|
||||||
|
{
|
||||||
|
"Annotations": {},
|
||||||
|
"Architecture": "amd64",
|
||||||
|
"Author": "",
|
||||||
|
"Comment": "from Bitnami with love",
|
||||||
|
"ContainerConfig": {
|
||||||
|
"Cmd": [
|
||||||
|
"nami",
|
||||||
|
"start",
|
||||||
|
"--foreground",
|
||||||
|
"wildfly"
|
||||||
|
],
|
||||||
|
"Entrypoint": [
|
||||||
|
"/app-entrypoint.sh"
|
||||||
|
],
|
||||||
|
"Env": [
|
||||||
|
"PATH=/opt/bitnami/java/bin:/opt/bitnami/wildfly/bin:/opt/bitnami/nami/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
|
"IMAGE_OS=debian-9",
|
||||||
|
"NAMI_VERSION=0.0.9-0",
|
||||||
|
"GPG_KEY_SERVERS_LIST=ha.pool.sks-keyservers.net \
|
||||||
|
hkp://p80.pool.sks-keyservers.net:80 keyserver.ubuntu.com hkp://keyserver.ubuntu.com:80 pgp.mit.edu",
|
||||||
|
"TINI_VERSION=v0.13.2",
|
||||||
|
"TINI_GPG_KEY=595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7",
|
||||||
|
"GOSU_VERSION=1.10",
|
||||||
|
"GOSU_GPG_KEY=B42F6819007F00F88E364FD4036A9C25BF357DD4",
|
||||||
|
"BITNAMI_IMAGE_VERSION=14.0.1-debian-9-r12",
|
||||||
|
"BITNAMI_APP_NAME=wildfly",
|
||||||
|
"WILDFLY_JAVA_HOME=",
|
||||||
|
"WILDFLY_JAVA_OPTS=",
|
||||||
|
"WILDFLY_MANAGEMENT_HTTP_PORT_NUMBER=9990",
|
||||||
|
"WILDFLY_PASSWORD=bitnami",
|
||||||
|
"WILDFLY_PUBLIC_CONSOLE=true",
|
||||||
|
"WILDFLY_SERVER_AJP_PORT_NUMBER=8009",
|
||||||
|
"WILDFLY_SERVER_HTTP_PORT_NUMBER=8080",
|
||||||
|
"WILDFLY_SERVER_INTERFACE=0.0.0.0",
|
||||||
|
"WILDFLY_USERNAME=user",
|
||||||
|
"WILDFLY_WILDFLY_HOME=/home/wildfly",
|
||||||
|
"WILDFLY_WILDFLY_OPTS=-Dwildfly.as.deployment.ondemand=false"
|
||||||
|
],
|
||||||
|
"ExposedPorts": {
|
||||||
|
"8080/tcp": {},
|
||||||
|
"9990/tcp": {}
|
||||||
|
},
|
||||||
|
"Labels": {
|
||||||
|
"maintainer": "Bitnami <containers@bitnami.com>"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Created": "2018-09-25T04:07:45.934395523Z",
|
||||||
|
"Digest": "sha256:5c7d8e2dd66dcf4a152a4032a1d3c5a33458c67e1c1335edd8d18d738892356b",
|
||||||
|
"GraphDriver": {
|
||||||
|
"Data": {
|
||||||
|
"LowerDir": "/var/lib/containers/storage/overlay/a9dbf5616cc16919a8ac0dfc60aff87a72b5be52994c4649fcc91a089a12931\
|
||||||
|
f/diff:/var/lib/containers/storage/overlay/67129bd46022122a7d8b7acb490092af6c7ce244ce4fbd7d9e2d2b7f5979e090/diff:/var/lib/containers/storage/overlay/7c51242c\
|
||||||
|
4c5db5c74afda76d7fdbeab6965d8b21804bb3fc597dee09c770b0ca/diff:/var/lib/containers/storage/overlay/f97315dc58a9c002ba0cabccb9933d4b0d2113733d204188c88d72f75569b57b/diff:/var/lib/containers/storage/overlay/1dbde2dd497ddde2b467727125b900958a051a72561e58d29abe3d660dcaa9a7/diff:/var/lib/containers/storage/overlay/4aad9d80f30c3f0608f58173558b7554d84dee4dc4479672926eca29f75e6e33/diff:/var/lib/containers/storage/overlay/6751fc9b6868254870c062d75a511543fc8cfda2ce6262f4945f107449219632/diff:/var/lib/containers/storage/overlay/a27034d79081347421dd24d7e9e776c18271cd9a6e51053cb39af4d3d9c400e8/diff:/var/lib/containers/storage/overlay/537cf0045ed9cd7989f7944e7393019c81b16c1799a2198d8348cd182665397f/diff:/var/lib/containers/storage/overlay/27578615c5ae352af4e8449862d61aaf5c11b105a7d5905af55bd01b0c656d6e/diff:/var/lib/containers/storage/overlay/566542742840fe3034b3596f7cb9e62a6274c95a69f368f9e713746f8712c0b6/diff",
|
||||||
|
"MergedDir": "/var/lib/containers/storage/overlay/72bb96d6\
|
||||||
|
c53ad57a0b1e44cab226a6251598accbead40b23fac89c19ad8c25ca/merged",
|
||||||
|
"UpperDir": "/var/lib/containers/storage/overlay/72bb96d6c53ad57a0b1e44cab226a6251598accbead40b23fac89c19ad8c25ca/diff",
|
||||||
|
"WorkDir": "/var/lib/containers/storage/overlay/72bb96d6c53ad57a0b1e44cab226a6251598accbead40b23fac89c19ad8c25ca/work"
|
||||||
|
},
|
||||||
|
"Name": "overlay"
|
||||||
|
},
|
||||||
|
"Id": "bcacbdf7a119c0fa934661ca8af839e625ce6540d9ceb6827cdd389f823d49e0",
|
||||||
|
"Labels": {
|
||||||
|
"maintainer": "Bitnami <containers@bitnami.com>"
|
||||||
|
},
|
||||||
|
"ManifestType": "application/vnd.docker.distribution.manifest.v1+prettyjws",
|
||||||
|
"Os": "linux",
|
||||||
|
"Parent": "",
|
||||||
|
"RepoDigests": [
|
||||||
|
"quay.io/bitnami/wildfly@sha256:5c7d8e2dd66dcf4a152a4032a1d3c5a33458c67e1c1335edd8d18d738892356b"
|
||||||
|
],
|
||||||
|
"RepoTags": [
|
||||||
|
"quay.io/bitnami/wildfly:latest"
|
||||||
|
],
|
||||||
|
"RootFS": {
|
||||||
|
"Layers": [
|
||||||
|
"sha256:75391df2c87e076b0c2f72d20c95c57dc8be7ee684cc07273416cce622b43367",
|
||||||
|
"sha256:7dd303f041039bfe8f0833092673ac35f93137d10e0fbc4302021ea65ad57731",
|
||||||
|
"sha256:720d9edf0cd2a9bb56b88b80be9070dbfaad359514c70094c65066963fed485d",
|
||||||
|
"sha256:6a567ecbf97725501a634fcb486271999aa4591b633b4ae9932a46b40f5aaf47",
|
||||||
|
"sha256:59e9a6db8f178f3da868614564faabb2820cdfb69be32e63a4405d6f7772f68c",
|
||||||
|
"sha256:310a82ccb092cd650215ab375da8943d235a263af9a029b8ac26a281446c04db",
|
||||||
|
"sha256:36cb91cf4513543a8f0953fed785747ea18b675bc2677f3839889cfca0aac79e"
|
||||||
|
],
|
||||||
|
"Type": "layers"
|
||||||
|
},
|
||||||
|
"Size": 569919342,
|
||||||
|
"User": "",
|
||||||
|
"Version": "17.06.0-ce",
|
||||||
|
"VirtualSize": 569919342
|
||||||
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
def image_exists(module, executable, name):
|
||||||
|
command = [executable, 'image', 'exists', name]
|
||||||
|
rc, out, err = module.run_command(command)
|
||||||
|
if rc == 1:
|
||||||
|
return False
|
||||||
|
elif 'Command "exists" not found' in err:
|
||||||
|
# The 'exists' test is available in podman >= 0.12.1
|
||||||
|
command = [executable, 'image', 'ls', '-q', name]
|
||||||
|
rc2, out2, err2 = module.run_command(command)
|
||||||
|
if rc2 != 0:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def filter_invalid_names(module, executable, name):
|
||||||
|
valid_names = []
|
||||||
|
names = name
|
||||||
|
if not isinstance(name, list):
|
||||||
|
names = [name]
|
||||||
|
|
||||||
|
for name in names:
|
||||||
|
if image_exists(module, executable, name):
|
||||||
|
valid_names.append(name)
|
||||||
|
|
||||||
|
return valid_names
|
||||||
|
|
||||||
|
|
||||||
|
def get_image_info(module, executable, name):
|
||||||
|
names = name
|
||||||
|
if not isinstance(name, list):
|
||||||
|
names = [name]
|
||||||
|
|
||||||
|
if len(names) > 0:
|
||||||
|
command = [executable, 'image', 'inspect']
|
||||||
|
command.extend(names)
|
||||||
|
rc, out, err = module.run_command(command)
|
||||||
|
|
||||||
|
if rc != 0:
|
||||||
|
module.fail_json(msg="Unable to gather info for '{0}': {1}".format(', '.join(names), err))
|
||||||
|
return out
|
||||||
|
|
||||||
|
else:
|
||||||
|
return json.dumps([])
|
||||||
|
|
||||||
|
|
||||||
|
def get_all_image_info(module, executable):
|
||||||
|
command = [executable, 'image', 'ls', '-q']
|
||||||
|
rc, out, err = module.run_command(command)
|
||||||
|
name = out.strip().split('\n')
|
||||||
|
out = get_image_info(module, executable, name)
|
||||||
|
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(
|
||||||
|
executable=dict(type='str', default='podman'),
|
||||||
|
name=dict(type='list')
|
||||||
|
),
|
||||||
|
supports_check_mode=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
executable = module.params['executable']
|
||||||
|
name = module.params.get('name')
|
||||||
|
executable = module.get_bin_path(executable, required=True)
|
||||||
|
|
||||||
|
if name:
|
||||||
|
valid_names = filter_invalid_names(module, executable, name)
|
||||||
|
results = json.loads(get_image_info(module, executable, valid_names))
|
||||||
|
else:
|
||||||
|
results = json.loads(get_all_image_info(module, executable))
|
||||||
|
|
||||||
|
results = dict(
|
||||||
|
changed=False,
|
||||||
|
images=results
|
||||||
|
)
|
||||||
|
|
||||||
|
module.exit_json(**results)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
104
plugins/modules/podman_volume_info.py
Normal file
104
plugins/modules/podman_volume_info.py
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2018 Ansible Project
|
||||||
|
# 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: podman_volume_info
|
||||||
|
author:
|
||||||
|
- "Sagi Shnaidman (@sshnaidm)"
|
||||||
|
short_description: Gather info about podman volumes
|
||||||
|
notes: []
|
||||||
|
description:
|
||||||
|
- Gather info about podman volumes with podman inspect command.
|
||||||
|
requirements:
|
||||||
|
- "Podman installed on host"
|
||||||
|
options:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Name of the volume
|
||||||
|
type: str
|
||||||
|
executable:
|
||||||
|
description:
|
||||||
|
- Path to C(podman) executable if it is not in the C($PATH) on the
|
||||||
|
machine running C(podman)
|
||||||
|
default: 'podman'
|
||||||
|
type: str
|
||||||
|
'''
|
||||||
|
EXAMPLES = """
|
||||||
|
- name: Gather info about all present volumes
|
||||||
|
podman_volume_info:
|
||||||
|
|
||||||
|
- name: Gather info about specific volume
|
||||||
|
podman_volume_info:
|
||||||
|
name: specific_volume
|
||||||
|
"""
|
||||||
|
RETURN = """
|
||||||
|
volumes:
|
||||||
|
description: Facts from all or specified volumes
|
||||||
|
returned: always
|
||||||
|
type: list
|
||||||
|
sample: [
|
||||||
|
{
|
||||||
|
"name": "testvolume",
|
||||||
|
"labels": {},
|
||||||
|
"mountPoint": "/home/ansible/.local/share/testvolume/_data",
|
||||||
|
"driver": "local",
|
||||||
|
"options": {},
|
||||||
|
"scope": "local"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
def get_volume_info(module, executable, name):
|
||||||
|
command = [executable, 'volume', 'inspect']
|
||||||
|
if name:
|
||||||
|
command.append(name)
|
||||||
|
else:
|
||||||
|
command.append("--all")
|
||||||
|
rc, out, err = module.run_command(command)
|
||||||
|
if rc != 0 or 'no such volume' in err:
|
||||||
|
module.fail_json(msg="Unable to gather info for %s: %s" % (name or 'all volumes', err))
|
||||||
|
if not out or json.loads(out) is None:
|
||||||
|
return [], out, err
|
||||||
|
return json.loads(out), out, err
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(
|
||||||
|
executable=dict(type='str', default='podman'),
|
||||||
|
name=dict(type='str')
|
||||||
|
),
|
||||||
|
supports_check_mode=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
name = module.params['name']
|
||||||
|
executable = module.get_bin_path(module.params['executable'], required=True)
|
||||||
|
|
||||||
|
inspect_results, out, err = get_volume_info(module, executable, name)
|
||||||
|
|
||||||
|
results = {
|
||||||
|
"changed": False,
|
||||||
|
"volumes": inspect_results,
|
||||||
|
"stderr": err
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exit_json(**results)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
1
tests/.gitignore
vendored
Normal file
1
tests/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
output/
|
||||||
0
tests/integration/targets/__init__.py
Normal file
0
tests/integration/targets/__init__.py
Normal file
1
tests/integration/targets/connection/aliases
Normal file
1
tests/integration/targets/connection/aliases
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
hidden
|
||||||
10
tests/integration/targets/connection/test.sh
Executable file
10
tests/integration/targets/connection/test.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
[ -f "${INVENTORY}" ]
|
||||||
|
|
||||||
|
# Run connection tests with both the default and C locale.
|
||||||
|
|
||||||
|
ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
|
||||||
|
LC_ALL=C LANG=C ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
|
||||||
43
tests/integration/targets/connection/test_connection.yml
Normal file
43
tests/integration/targets/connection/test_connection.yml
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
- hosts: "{{ target_hosts }}"
|
||||||
|
gather_facts: no
|
||||||
|
serial: 1
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
### raw with unicode arg and output
|
||||||
|
|
||||||
|
- name: raw with unicode arg and output
|
||||||
|
raw: echo 汉语
|
||||||
|
register: command
|
||||||
|
- name: check output of raw with unicode arg and output
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'汉语' in command.stdout"
|
||||||
|
- command is changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules
|
||||||
|
|
||||||
|
### copy local file with unicode filename and content
|
||||||
|
|
||||||
|
- name: create local file with unicode filename and content
|
||||||
|
local_action: lineinfile dest={{ local_tmp }}-汉语/汉语.txt create=true line=汉语
|
||||||
|
- name: remove remote file with unicode filename and content
|
||||||
|
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语/汉语.txt state=absent"
|
||||||
|
- name: create remote directory with unicode name
|
||||||
|
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=directory"
|
||||||
|
- name: copy local file with unicode filename and content
|
||||||
|
action: "{{ action_prefix }}copy src={{ local_tmp }}-汉语/汉语.txt dest={{ remote_tmp }}-汉语/汉语.txt"
|
||||||
|
|
||||||
|
### fetch remote file with unicode filename and content
|
||||||
|
|
||||||
|
- name: remove local file with unicode filename and content
|
||||||
|
local_action: file path={{ local_tmp }}-汉语/汉语.txt state=absent
|
||||||
|
- name: fetch remote file with unicode filename and content
|
||||||
|
fetch: src={{ remote_tmp }}-汉语/汉语.txt dest={{ local_tmp }}-汉语/汉语.txt fail_on_missing=true validate_checksum=true flat=true
|
||||||
|
|
||||||
|
### remove local and remote temp files
|
||||||
|
|
||||||
|
- name: remove local temp file
|
||||||
|
local_action: file path={{ local_tmp }}-汉语 state=absent
|
||||||
|
- name: remove remote temp file
|
||||||
|
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=absent"
|
||||||
|
|
||||||
|
### test wait_for_connection plugin
|
||||||
|
- wait_for_connection:
|
||||||
3
tests/integration/targets/connection_buildah/aliases
Normal file
3
tests/integration/targets/connection_buildah/aliases
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
needs/root
|
||||||
|
non_local
|
||||||
|
unsupported
|
||||||
1
tests/integration/targets/connection_buildah/posix.sh
Symbolic link
1
tests/integration/targets/connection_buildah/posix.sh
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../connection_posix/test.sh
|
||||||
7
tests/integration/targets/connection_buildah/runme.sh
Executable file
7
tests/integration/targets/connection_buildah/runme.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
./posix.sh "$@"
|
||||||
|
|
||||||
|
ANSIBLE_REMOTE_USER="1000" ./posix.sh "$@"
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
[buildah]
|
||||||
|
buildah-container ansible_ssh_pipelining=true
|
||||||
|
[buildah:vars]
|
||||||
|
# 1. install buildah
|
||||||
|
# 2. create container:
|
||||||
|
# $ sudo buildah from --name=buildah-container python:2
|
||||||
|
# 3. run test:
|
||||||
|
# $ ansible-test integration connection_buildah
|
||||||
|
# 6. remove container
|
||||||
|
# $ sudo buildah rm buildah-container
|
||||||
|
ansible_host=buildah-container
|
||||||
|
ansible_connection=buildah
|
||||||
2
tests/integration/targets/connection_podman/aliases
Normal file
2
tests/integration/targets/connection_podman/aliases
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
non_local
|
||||||
|
unsupported
|
||||||
18
tests/integration/targets/connection_podman/posix.sh
Executable file
18
tests/integration/targets/connection_podman/posix.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
# Connection tests for POSIX platforms use this script by linking to it from the appropriate 'connection_' target dir.
|
||||||
|
# The name of the inventory group to test is extracted from the directory name following the 'connection_' prefix.
|
||||||
|
|
||||||
|
group=$(python -c \
|
||||||
|
"from os import path; print(path.basename(path.abspath(path.dirname('$0'))).replace('connection_', ''))")
|
||||||
|
|
||||||
|
cd ../connection
|
||||||
|
|
||||||
|
INVENTORY="../connection_${group}/test_connection.inventory" ./test.sh \
|
||||||
|
-e target_hosts="${group}" \
|
||||||
|
-e action_prefix= \
|
||||||
|
-e local_tmp=/tmp/ansible-local \
|
||||||
|
-e remote_tmp=/tmp/ansible-remote \
|
||||||
|
"$@"
|
||||||
14
tests/integration/targets/connection_podman/runme.sh
Executable file
14
tests/integration/targets/connection_podman/runme.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
./posix.sh "$@"
|
||||||
|
|
||||||
|
ANSIBLE_REMOTE_TMP="/tmp" ANSIBLE_REMOTE_USER="1000" ./posix.sh "$@"
|
||||||
|
ANSIBLE_PODMAN_EXECUTABLE=fakepodman ./posix.sh "$@" 2>&1 | grep "fakepodman command not found in PATH"
|
||||||
|
|
||||||
|
ANSIBLE_PODMAN_EXECUTABLE=fakepodman ./posix.sh "$@" && {
|
||||||
|
echo "Playbook with fakepodman should fail!"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
ANSIBLE_VERBOSITY=4 ANSIBLE_PODMAN_EXTRA_ARGS=" --log-level debug " ./posix.sh "$@" | grep "level=debug msg="
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
[podman]
|
||||||
|
podman-container
|
||||||
|
[podman:vars]
|
||||||
|
# 1. install podman
|
||||||
|
# 2. create container:
|
||||||
|
# podman pull python:3-alpine
|
||||||
|
# podman run -d --name podman-container python:3-alpine sleep 999999
|
||||||
|
# 3. run test:
|
||||||
|
# ./bin/ansible-test integration connection_podman
|
||||||
|
# 6. remove container
|
||||||
|
# podman stop podman-container
|
||||||
|
# podman rm podman-container
|
||||||
|
ansible_host=podman-container
|
||||||
|
ansible_connection=podman
|
||||||
|
ansible_python_interpreter=/usr/local/bin/python
|
||||||
2
tests/integration/targets/connection_posix/aliases
Normal file
2
tests/integration/targets/connection_posix/aliases
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
needs/target/connection
|
||||||
|
hidden
|
||||||
18
tests/integration/targets/connection_posix/test.sh
Executable file
18
tests/integration/targets/connection_posix/test.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
# Connection tests for POSIX platforms use this script by linking to it from the appropriate 'connection_' target dir.
|
||||||
|
# The name of the inventory group to test is extracted from the directory name following the 'connection_' prefix.
|
||||||
|
|
||||||
|
group=$(python -c \
|
||||||
|
"from os import path; print(path.basename(path.abspath(path.dirname('$0'))).replace('connection_', ''))")
|
||||||
|
|
||||||
|
cd ../connection
|
||||||
|
|
||||||
|
INVENTORY="../connection_${group}/test_connection.inventory" ./test.sh \
|
||||||
|
-e target_hosts="${group}" \
|
||||||
|
-e action_prefix= \
|
||||||
|
-e local_tmp=/tmp/ansible-local \
|
||||||
|
-e remote_tmp=/tmp/ansible-remote \
|
||||||
|
"$@"
|
||||||
5
tests/integration/targets/podman_container_info/aliases
Normal file
5
tests/integration/targets/podman_container_info/aliases
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
shippable/posix/group2
|
||||||
|
skip/aix
|
||||||
|
skip/osx
|
||||||
|
skip/freebsd
|
||||||
|
destructive
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- setup_podman
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
- name: Test podman_container_info
|
||||||
|
when:
|
||||||
|
- ansible_facts.virtualization_type != 'docker'
|
||||||
|
- ansible_facts.distribution == 'RedHat'
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: Generate random value for container name
|
||||||
|
set_fact:
|
||||||
|
container_name: "{{ 'ansible-test-podman-%0x' % ((2**32) | random) }}"
|
||||||
|
|
||||||
|
- name: Make sure container doesn't exist
|
||||||
|
command: podman container rm -f {{ container_name }}
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Get missing container info
|
||||||
|
podman_container_info:
|
||||||
|
name: "{{ container_name }}"
|
||||||
|
register: nonexist
|
||||||
|
|
||||||
|
- name: Check results of missing container info
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'containers' in nonexist"
|
||||||
|
- nonexist is succeeded
|
||||||
|
- nonexist.containers == []
|
||||||
|
|
||||||
|
- name: Get missing multiple container info
|
||||||
|
podman_container_info:
|
||||||
|
name:
|
||||||
|
- "{{ container_name }}"
|
||||||
|
- neverexist
|
||||||
|
- whatever
|
||||||
|
register: nonexist2
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Check results of missing multiple container info
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'containers' in nonexist2"
|
||||||
|
- nonexist2 is succeeded
|
||||||
|
- nonexist2.containers == []
|
||||||
|
|
||||||
|
- name: Make sure container exists
|
||||||
|
command: podman container run -d --name {{ container_name }} alpine sleep 15m
|
||||||
|
|
||||||
|
- name: Get existing container info
|
||||||
|
podman_container_info:
|
||||||
|
name: "{{ container_name }}"
|
||||||
|
register: existing_container
|
||||||
|
|
||||||
|
- name: Get mixed existing and non-existing container info
|
||||||
|
podman_container_info:
|
||||||
|
name:
|
||||||
|
- "{{ container_name }}"
|
||||||
|
- whatever
|
||||||
|
register: mixed_existing_container
|
||||||
|
|
||||||
|
- name: Get all containers info
|
||||||
|
podman_container_info:
|
||||||
|
register: all_containers
|
||||||
|
|
||||||
|
- name: Dump podman container inspect result
|
||||||
|
debug: var=existing_container
|
||||||
|
|
||||||
|
- name: Comparison with 'podman container inspect'
|
||||||
|
command: podman container inspect "{{ container_name }}"
|
||||||
|
register: podman_inspect
|
||||||
|
|
||||||
|
- name: Convert podman inspect output to JSON
|
||||||
|
set_fact:
|
||||||
|
podman_inspect_result: "{{ podman_inspect.stdout | from_json }}"
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
command: podman container rm -f {{ container_name }}
|
||||||
|
|
||||||
|
- name: Make checks
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'containers' in existing_container"
|
||||||
|
- existing_container.containers
|
||||||
|
- "existing_container.containers == podman_inspect_result"
|
||||||
|
- all_containers.containers == existing_container.containers
|
||||||
|
- "'containers' in mixed_existing_container"
|
||||||
|
- mixed_existing_container.containers
|
||||||
|
- existing_container.containers == mixed_existing_container.containers
|
||||||
|
|
||||||
|
always:
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
command: podman container rm -f {{ container_name }}
|
||||||
|
ignore_errors: true
|
||||||
5
tests/integration/targets/podman_image/aliases
Normal file
5
tests/integration/targets/podman_image/aliases
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
shippable/posix/group3
|
||||||
|
skip/aix
|
||||||
|
skip/osx
|
||||||
|
skip/freebsd
|
||||||
|
destructive
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
FROM quay.io/coreos/alpine-sh
|
||||||
|
ENV VAR testing
|
||||||
|
WORKDIR ${VAR}
|
||||||
2
tests/integration/targets/podman_image/meta/main.yml
Normal file
2
tests/integration/targets/podman_image/meta/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- setup_podman
|
||||||
144
tests/integration/targets/podman_image/tasks/main.yml
Normal file
144
tests/integration/targets/podman_image/tasks/main.yml
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
- name: Test podman_image
|
||||||
|
when:
|
||||||
|
- ansible_facts.virtualization_type != 'docker'
|
||||||
|
- ansible_facts.distribution == 'RedHat'
|
||||||
|
block:
|
||||||
|
- name: Pull image
|
||||||
|
podman_image:
|
||||||
|
name: quay.io/coreos/alpine-sh
|
||||||
|
register: pull1
|
||||||
|
|
||||||
|
- name: Pull image again
|
||||||
|
podman_image:
|
||||||
|
name: quay.io/coreos/alpine-sh
|
||||||
|
register: pull2
|
||||||
|
|
||||||
|
- name: List images
|
||||||
|
command: podman image ls
|
||||||
|
register: images
|
||||||
|
|
||||||
|
- name: Ensure image was pulled properly
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pull1 is changed
|
||||||
|
- pull2 is not changed
|
||||||
|
- "'alpine-sh' in images.stdout"
|
||||||
|
|
||||||
|
- name: Remove image
|
||||||
|
podman_image:
|
||||||
|
name: quay.io/coreos/alpine-sh
|
||||||
|
state: absent
|
||||||
|
register: rmi1
|
||||||
|
|
||||||
|
- name: Remove image again
|
||||||
|
podman_image:
|
||||||
|
name: quay.io/coreos/alpine-sh
|
||||||
|
state: absent
|
||||||
|
register: rmi2
|
||||||
|
|
||||||
|
- name: List images
|
||||||
|
command: podman image ls
|
||||||
|
register: images
|
||||||
|
|
||||||
|
- name: Ensure image was removed properly
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- rmi1 is changed
|
||||||
|
- rmi2 is not changed
|
||||||
|
- "'alpine-sh' not in images.stdout"
|
||||||
|
|
||||||
|
- name: Pull a specific version of an image
|
||||||
|
podman_image:
|
||||||
|
name: quay.io/coreos/etcd
|
||||||
|
tag: v3.3.11
|
||||||
|
register: specific_image1
|
||||||
|
|
||||||
|
- name: Pull a specific version of an image again
|
||||||
|
podman_image:
|
||||||
|
name: quay.io/coreos/etcd
|
||||||
|
tag: v3.3.11
|
||||||
|
register: specific_image2
|
||||||
|
|
||||||
|
- name: List images
|
||||||
|
command: podman image ls
|
||||||
|
register: images
|
||||||
|
|
||||||
|
- name: Ensure specific image was pulled properly
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- specific_image1 is changed
|
||||||
|
- specific_image2 is not changed
|
||||||
|
- "'v3.3.11' in images.stdout"
|
||||||
|
|
||||||
|
- name: Create a build dir
|
||||||
|
file:
|
||||||
|
path: /var/tmp/build
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Copy Containerfile
|
||||||
|
copy:
|
||||||
|
src: Containerfile
|
||||||
|
dest: /var/tmp/build/Dockerfile
|
||||||
|
|
||||||
|
- name: Build OCI image
|
||||||
|
podman_image:
|
||||||
|
name: testimage
|
||||||
|
path: /var/tmp/build
|
||||||
|
register: oci_build1
|
||||||
|
|
||||||
|
- name: Build OCI image again
|
||||||
|
podman_image:
|
||||||
|
name: testimage
|
||||||
|
path: /var/tmp/build
|
||||||
|
register: oci_build2
|
||||||
|
|
||||||
|
- name: Inspect build image
|
||||||
|
podman_image_info:
|
||||||
|
name: testimage
|
||||||
|
register: testimage_info
|
||||||
|
|
||||||
|
- name: Ensure OCI image was built properly
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- oci_build1 is changed
|
||||||
|
- oci_build2 is not changed
|
||||||
|
- "'localhost/testimage:latest' in testimage_info.images[0]['RepoTags'][0]"
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
podman_image:
|
||||||
|
name: dockerimage
|
||||||
|
path: /var/tmp/build
|
||||||
|
build:
|
||||||
|
format: docker
|
||||||
|
register: docker_build1
|
||||||
|
|
||||||
|
- name: Build Docker image again
|
||||||
|
podman_image:
|
||||||
|
name: dockerimage
|
||||||
|
path: /var/tmp/build
|
||||||
|
build:
|
||||||
|
format: docker
|
||||||
|
register: docker_build2
|
||||||
|
|
||||||
|
- name: Inspect build image
|
||||||
|
podman_image_info:
|
||||||
|
name: dockerimage
|
||||||
|
register: dockerimage_info
|
||||||
|
|
||||||
|
- name: Ensure Docker image was built properly
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- docker_build1 is changed
|
||||||
|
- docker_build2 is not changed
|
||||||
|
- "'localhost/dockerimage:latest' in dockerimage_info.images[0]['RepoTags'][0]"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Cleanup images
|
||||||
|
podman_image:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
loop:
|
||||||
|
- quay.io/coreos/alpine-sh
|
||||||
|
- quay.io/coreos/etcd:v3.3.11
|
||||||
|
- localhost/testimage
|
||||||
|
- localhost/dockerimage
|
||||||
5
tests/integration/targets/podman_image_info/aliases
Normal file
5
tests/integration/targets/podman_image_info/aliases
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
shippable/posix/group2
|
||||||
|
skip/aix
|
||||||
|
skip/osx
|
||||||
|
skip/freebsd
|
||||||
|
destructive
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- setup_podman
|
||||||
53
tests/integration/targets/podman_image_info/tasks/main.yml
Normal file
53
tests/integration/targets/podman_image_info/tasks/main.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
- name: Test podman_image_info
|
||||||
|
when:
|
||||||
|
- ansible_facts.virtualization_type != 'docker'
|
||||||
|
- ansible_facts.distribution == 'RedHat'
|
||||||
|
block:
|
||||||
|
- name: Pull image
|
||||||
|
command: podman pull quay.io/coreos/etcd
|
||||||
|
|
||||||
|
- name: Get info on all images
|
||||||
|
podman_image_info:
|
||||||
|
register: all_image_result
|
||||||
|
|
||||||
|
- name: Pull another image
|
||||||
|
command: podman pull quay.io/coreos/dnsmasq
|
||||||
|
|
||||||
|
- name: Get info on specific image
|
||||||
|
podman_image_info:
|
||||||
|
name: dnsmasq
|
||||||
|
register: named_image_result
|
||||||
|
|
||||||
|
- name:
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- all_image_result.images | length > 0
|
||||||
|
- named_image_result.images | length == 1
|
||||||
|
- "'dnsmasq' in named_image_result.images[0]['RepoTags'][0]"
|
||||||
|
|
||||||
|
- name: Get info on single image that does not exist
|
||||||
|
podman_image_info:
|
||||||
|
name: nope
|
||||||
|
register: single_nonexistant
|
||||||
|
|
||||||
|
- name: Get info on multiple images that do not exist
|
||||||
|
podman_image_info:
|
||||||
|
name:
|
||||||
|
- nope
|
||||||
|
- reallynope
|
||||||
|
register: multiple_nonexistant
|
||||||
|
|
||||||
|
- name: Get info with one image that does not exist
|
||||||
|
podman_image_info:
|
||||||
|
name:
|
||||||
|
- dnsmasq
|
||||||
|
- nope
|
||||||
|
- etcd
|
||||||
|
register: mixed_nonexistant
|
||||||
|
|
||||||
|
- name: Ensure image info was returned when non-existant image info was requisted
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- single_nonexistant.images | length == 0
|
||||||
|
- multiple_nonexistant.images | length == 0
|
||||||
|
- mixed_nonexistant.images | length == 2
|
||||||
5
tests/integration/targets/podman_volume_info/aliases
Normal file
5
tests/integration/targets/podman_volume_info/aliases
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
shippable/posix/group2
|
||||||
|
skip/aix
|
||||||
|
skip/osx
|
||||||
|
skip/freebsd
|
||||||
|
destructive
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- setup_podman
|
||||||
62
tests/integration/targets/podman_volume_info/tasks/main.yml
Normal file
62
tests/integration/targets/podman_volume_info/tasks/main.yml
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
- name: Test podman_volume_info
|
||||||
|
when:
|
||||||
|
- ansible_facts.virtualization_type != 'docker'
|
||||||
|
- ansible_facts.distribution == 'RedHat'
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: Print podman version
|
||||||
|
command: podman version
|
||||||
|
|
||||||
|
- name: Generate random value for volume name
|
||||||
|
set_fact:
|
||||||
|
volume_name: "{{ 'ansible-test-podman-%0x' % ((2**32) | random) }}"
|
||||||
|
|
||||||
|
- name: Make sure volume doesn't exist
|
||||||
|
command: podman volume rm {{ volume_name }}
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Get missing volume info
|
||||||
|
podman_volume_info:
|
||||||
|
name: "{{ volume_name }}"
|
||||||
|
register: nonexist
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Check results
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'volumes' not in nonexist"
|
||||||
|
- nonexist is failed
|
||||||
|
|
||||||
|
- name: Make sure volume exists
|
||||||
|
command: podman volume create {{ volume_name }}
|
||||||
|
|
||||||
|
- name: Get existing volume info
|
||||||
|
podman_volume_info:
|
||||||
|
name: "{{ volume_name }}"
|
||||||
|
register: existing_volume
|
||||||
|
|
||||||
|
- name: Dump podman volume inspect result
|
||||||
|
debug: var=existing_volume
|
||||||
|
|
||||||
|
- name: Comparison with 'podman volume inspect'
|
||||||
|
command: podman volume inspect "{{ volume_name }}"
|
||||||
|
register: podman_inspect
|
||||||
|
|
||||||
|
- name: Convert podman inspect output to JSON
|
||||||
|
set_fact:
|
||||||
|
podman_inspect_result: "{{ podman_inspect.stdout | from_json }}"
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
command: podman volume rm {{ volume_name }}
|
||||||
|
|
||||||
|
- name: Make checks
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'volumes' in existing_volume"
|
||||||
|
- existing_volume.volumes
|
||||||
|
- "existing_volume.volumes == podman_inspect_result"
|
||||||
|
always:
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
command: podman volume rm {{ volume_name }}
|
||||||
|
ignore_errors: true
|
||||||
1
tests/integration/targets/setup_podman/defaults/main.yml
Normal file
1
tests/integration/targets/setup_podman/defaults/main.yml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
podman_package: podman-1.4.*
|
||||||
9
tests/integration/targets/setup_podman/handlers/main.yml
Normal file
9
tests/integration/targets/setup_podman/handlers/main.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
- name: remove podman packages
|
||||||
|
yum:
|
||||||
|
name: 'podman*'
|
||||||
|
state: absent
|
||||||
|
listen: cleanup podman
|
||||||
|
|
||||||
|
- name: remove extras repo
|
||||||
|
command: "{{ repo_command[ansible_facts.distribution ~ ansible_facts.distribution_major_version]['disable'] | default('echo') }}"
|
||||||
|
listen: cleanup podman
|
||||||
19
tests/integration/targets/setup_podman/tasks/main.yml
Normal file
19
tests/integration/targets/setup_podman/tasks/main.yml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
- block:
|
||||||
|
- name: Enable extras repo
|
||||||
|
command: "{{ repo_command[ansible_facts.distribution ~ ansible_facts.distribution_major_version]['enable'] | default('echo') }}"
|
||||||
|
notify: cleanup podman
|
||||||
|
|
||||||
|
- name: Install podman
|
||||||
|
yum:
|
||||||
|
name: "{{ podman_package }}"
|
||||||
|
state: present
|
||||||
|
when: ansible_facts.pkg_mgr in ['yum', 'dnf']
|
||||||
|
notify: cleanup podman
|
||||||
|
|
||||||
|
- name: Get podman version
|
||||||
|
command: podman --version
|
||||||
|
|
||||||
|
when:
|
||||||
|
- ansible_facts.distribution == 'RedHat'
|
||||||
|
- ansible_facts.virtualization_type != 'docker'
|
||||||
|
- ansible_facts.distribution_major_version is version_compare('7', '>=')
|
||||||
4
tests/integration/targets/setup_podman/vars/main.yml
Normal file
4
tests/integration/targets/setup_podman/vars/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
repo_command:
|
||||||
|
RedHat7:
|
||||||
|
enable: yum-config-manager --enable rhui-REGION-rhel-server-extras
|
||||||
|
disable: yum-config-manager --disable rhui-REGION-rhel-server-extras
|
||||||
7
tests/sanity/ignore-2.10.txt
Normal file
7
tests/sanity/ignore-2.10.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
plugins/modules/podman_image.py validate-modules:doc-type-does-not-match-spec
|
||||||
|
plugins/modules/podman_image.py validate-modules:mutually_exclusive-unknown
|
||||||
|
plugins/modules/podman_image.py validate-modules:parameter-list-no-elements
|
||||||
|
plugins/modules/podman_image.py validate-modules:parameter-type-not-in-doc
|
||||||
|
plugins/modules/podman_image.py validate-modules:undocumented-parameter
|
||||||
|
plugins/modules/podman_image_info.py validate-modules:parameter-list-no-elements
|
||||||
|
plugins/modules/podman_image_info.py validate-modules:parameter-type-not-in-doc
|
||||||
4
tests/sanity/ignore-2.9.txt
Normal file
4
tests/sanity/ignore-2.9.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
plugins/modules/podman_image.py validate-modules:doc-type-does-not-match-spec
|
||||||
|
plugins/modules/podman_image.py validate-modules:parameter-type-not-in-doc
|
||||||
|
plugins/modules/podman_image.py validate-modules:undocumented-parameter
|
||||||
|
plugins/modules/podman_image_info.py validate-modules:parameter-type-not-in-doc
|
||||||
4
tests/sanity/requirements.txt
Normal file
4
tests/sanity/requirements.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
packaging # needed for update-bundled and changelog
|
||||||
|
sphinx ; python_version >= '3.5' # docs build requires python 3+
|
||||||
|
sphinx-notfound-page ; python_version >= '3.5' # docs build requires python 3+
|
||||||
|
straight.plugin ; python_version >= '3.5' # needed for hacking/build-ansible.py which will host changelog generation and requires python 3+
|
||||||
Loading…
Add table
Add a link
Reference in a new issue