l*.py: normalize docs (#9390)

pull/9101/merge
Alexei Znamensky 2024-12-26 21:12:05 +13:00 committed by GitHub
parent 6b7ea3443d
commit cea6eeef37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 1194 additions and 1350 deletions

View File

@ -8,8 +8,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
---
module: launchd module: launchd
author: author:
- Martin Migasiewicz (@martinm82) - Martin Migasiewicz (@martinm82)
@ -38,39 +37,34 @@ options:
version_added: 10.1.0 version_added: 10.1.0
state: state:
description: description:
- V(started)/V(stopped) are idempotent actions that will not run - V(started)/V(stopped) are idempotent actions that will not run commands unless necessary.
commands unless necessary. - Launchd does not support V(restarted) nor V(reloaded) natively. These will trigger a stop/start (restarted) or an unload/load (reloaded).
- Launchd does not support V(restarted) nor V(reloaded) natively. - V(restarted) unloads and loads the service before start to ensure that the latest job definition (plist) is used.
These will trigger a stop/start (restarted) or an unload/load - V(reloaded) unloads and loads the service to ensure that the latest job definition (plist) is used. Whether a service is started or stopped
(reloaded). depends on the content of the definition file.
- V(restarted) unloads and loads the service before start to ensure
that the latest job definition (plist) is used.
- V(reloaded) unloads and loads the service to ensure that the latest
job definition (plist) is used. Whether a service is started or
stopped depends on the content of the definition file.
type: str type: str
choices: [ reloaded, restarted, started, stopped, unloaded ] choices: [reloaded, restarted, started, stopped, unloaded]
enabled: enabled:
description: description:
- Whether the service should start on boot. - Whether the service should start on boot.
- B(At least one of state and enabled are required.) - B(At least one of state and enabled are required).
type: bool type: bool
force_stop: force_stop:
description: description:
- Whether the service should not be restarted automatically by launchd. - Whether the service should not be restarted automatically by launchd.
- Services might have the 'KeepAlive' attribute set to true in a launchd configuration. - Services might have the 'KeepAlive' attribute set to true in a launchd configuration. In case this is set to true, stopping a service
In case this is set to true, stopping a service will cause that launchd starts the service again. will cause that launchd starts the service again.
- Set this option to V(true) to let this module change the 'KeepAlive' attribute to V(false). - Set this option to V(true) to let this module change the C(KeepAlive) attribute to V(false).
type: bool type: bool
default: false default: false
notes: notes:
- A user must privileged to manage services using this module. - A user must privileged to manage services using this module.
requirements: requirements:
- A system managed by launchd - A system managed by launchd
- The plistlib python library - The plistlib Python library
''' """
EXAMPLES = r''' EXAMPLES = r"""
- name: Make sure spotify webhelper is started - name: Make sure spotify webhelper is started
community.general.launchd: community.general.launchd:
name: com.spotify.webhelper name: com.spotify.webhelper
@ -112,11 +106,11 @@ EXAMPLES = r'''
name: com.openssh.sshd name: com.openssh.sshd
plist: ssh.plist plist: ssh.plist
state: restarted state: restarted
''' """
RETURN = r''' RETURN = r"""
status: status:
description: Metadata about service status description: Metadata about service status.
returned: always returned: always
type: dict type: dict
sample: sample:
@ -126,7 +120,7 @@ status:
"previous_pid": "82636", "previous_pid": "82636",
"previous_state": "running" "previous_state": "running"
} }
''' """
import os import os
import plistlib import plistlib

View File

@ -10,14 +10,13 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: layman module: layman
author: "Jakub Jirutka (@jirutka)" author: "Jakub Jirutka (@jirutka)"
short_description: Manage Gentoo overlays short_description: Manage Gentoo overlays
description: description:
- Uses Layman to manage an additional repositories for the Portage package manager on Gentoo Linux. - Uses Layman to manage an additional repositories for the Portage package manager on Gentoo Linux. Please note that Layman must be installed
Please note that Layman must be installed on a managed node prior using this module. on a managed node prior using this module.
requirements: requirements:
- layman python module - layman python module
extends_documentation_fragment: extends_documentation_fragment:
@ -30,15 +29,13 @@ attributes:
options: options:
name: name:
description: description:
- The overlay id to install, synchronize, or uninstall. - The overlay id to install, synchronize, or uninstall. Use V(ALL) to sync all of the installed overlays (can be used only when O(state=updated)).
Use 'ALL' to sync all of the installed overlays (can be used only when O(state=updated)).
required: true required: true
type: str type: str
list_url: list_url:
description: description:
- An URL of the alternative overlays list that defines the overlay to install. - An URL of the alternative overlays list that defines the overlay to install. This list will be fetched and saved under C(${overlay_defs}/${name}.xml),
This list will be fetched and saved under C(${overlay_defs}/${name}.xml), where where C(overlay_defs) is read from the Layman's configuration.
C(overlay_defs) is read from the Layman's configuration.
aliases: [url] aliases: [url]
type: str type: str
state: state:
@ -49,14 +46,13 @@ options:
type: str type: str
validate_certs: validate_certs:
description: description:
- If V(false), SSL certificates will not be validated. This should only be - If V(false), SSL certificates will not be validated. This should only be set to V(false) when no other option exists. Prior to 1.9.3 the
set to V(false) when no other option exists. Prior to 1.9.3 the code code defaulted to V(false).
defaulted to V(false).
type: bool type: bool
default: true default: true
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Install the overlay mozilla which is on the central overlays list - name: Install the overlay mozilla which is on the central overlays list
community.general.layman: community.general.layman:
name: mozilla name: mozilla
@ -81,7 +77,7 @@ EXAMPLES = '''
community.general.layman: community.general.layman:
name: cvut name: cvut
state: absent state: absent
''' """
import shutil import shutil
import traceback import traceback

View File

@ -8,8 +8,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: lbu module: lbu
short_description: Local Backup Utility for Alpine Linux short_description: Local Backup Utility for Alpine Linux
@ -17,8 +16,7 @@ short_description: Local Backup Utility for Alpine Linux
version_added: '0.2.0' version_added: '0.2.0'
description: description:
- Manage Local Backup Utility of Alpine Linux in run-from-RAM mode - Manage Local Backup Utility of Alpine Linux in run-from-RAM mode.
extends_documentation_fragment: extends_documentation_fragment:
- community.general.attributes - community.general.attributes
@ -46,9 +44,9 @@ options:
author: author:
- Kaarle Ritvanen (@kunkku) - Kaarle Ritvanen (@kunkku)
''' """
EXAMPLES = ''' EXAMPLES = r"""
# Commit changed files (if any) # Commit changed files (if any)
- name: Commit - name: Commit
community.general.lbu: community.general.lbu:
@ -67,14 +65,14 @@ EXAMPLES = '''
include: include:
- /root/.ssh/authorized_keys - /root/.ssh/authorized_keys
- /var/lib/misc - /var/lib/misc
''' """
RETURN = ''' RETURN = r"""
msg: msg:
description: Error message description: Error message.
type: str type: str
returned: on failure returned: on failure
''' """
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule

View File

@ -12,27 +12,19 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
---
module: ldap_attrs module: ldap_attrs
short_description: Add or remove multiple LDAP attribute values short_description: Add or remove multiple LDAP attribute values
description: description:
- Add or remove multiple LDAP attribute values. - Add or remove multiple LDAP attribute values.
notes: notes:
- This only deals with attributes on existing entries. To add or remove - This only deals with attributes on existing entries. To add or remove whole entries, see M(community.general.ldap_entry).
whole entries, see M(community.general.ldap_entry). - The default authentication settings will attempt to use a SASL EXTERNAL bind over a UNIX domain socket. This works well with the default Ubuntu
- The default authentication settings will attempt to use a SASL EXTERNAL install for example, which includes a C(cn=peercred,cn=external,cn=auth) ACL rule allowing root to modify the server configuration. If you need
bind over a UNIX domain socket. This works well with the default Ubuntu to use a simple bind to access your server, pass the credentials in O(bind_dn) and O(bind_pw).
install for example, which includes a cn=peercred,cn=external,cn=auth ACL - For O(state=present) and O(state=absent), all value comparisons are performed on the server for maximum accuracy. For O(state=exact), values
rule allowing root to modify the server configuration. If you need to use have to be compared in Python, which obviously ignores LDAP matching rules. This should work out in most cases, but it is theoretically possible
a simple bind to access your server, pass the credentials in O(bind_dn) to see spurious changes when target and actual values are semantically identical but lexically distinct.
and O(bind_pw).
- For O(state=present) and O(state=absent), all value comparisons are
performed on the server for maximum accuracy. For O(state=exact), values
have to be compared in Python, which obviously ignores LDAP matching
rules. This should work out in most cases, but it is theoretically
possible to see spurious changes when target and actual values are
semantically identical but lexically distinct.
version_added: '0.2.0' version_added: '0.2.0'
author: author:
- Jiri Tyr (@jtyr) - Jiri Tyr (@jtyr)
@ -53,41 +45,33 @@ options:
choices: [present, absent, exact] choices: [present, absent, exact]
default: present default: present
description: description:
- The state of the attribute values. If V(present), all given attribute - The state of the attribute values. If V(present), all given attribute values will be added if they are missing. If V(absent), all given
values will be added if they're missing. If V(absent), all given attribute values will be removed if present. If V(exact), the set of attribute values will be forced to exactly those provided and no
attribute values will be removed if present. If V(exact), the set of others. If O(state=exact) and the attribute value is empty, all values for this attribute will be removed.
attribute values will be forced to exactly those provided and no others.
If O(state=exact) and the attribute value is empty, all values for
this attribute will be removed.
attributes: attributes:
required: true required: true
type: dict type: dict
description: description:
- The attribute(s) and value(s) to add or remove. - The attribute(s) and value(s) to add or remove.
- Each attribute value can be a string for single-valued attributes or - Each attribute value can be a string for single-valued attributes or a list of strings for multi-valued attributes.
a list of strings for multi-valued attributes. - If you specify values for this option in YAML, please note that you can improve readability for long string values by using YAML block
- If you specify values for this option in YAML, please note that you can improve modifiers as seen in the examples for this module.
readability for long string values by using YAML block modifiers as seen in the - Note that when using values that YAML/ansible-core interprets as other types, like V(yes), V(no) (booleans), or V(2.10) (float), make
examples for this module. sure to quote them if these are meant to be strings. Otherwise the wrong values may be sent to LDAP.
- Note that when using values that YAML/ansible-core interprets as other types,
like V(yes), V(no) (booleans), or V(2.10) (float), make sure to quote them if
these are meant to be strings. Otherwise the wrong values may be sent to LDAP.
ordered: ordered:
required: false required: false
type: bool type: bool
default: false default: false
description: description:
- If V(true), prepend list values with X-ORDERED index numbers in all - If V(true), prepend list values with X-ORDERED index numbers in all attributes specified in the current task. This is useful mostly with
attributes specified in the current task. This is useful mostly with
C(olcAccess) attribute to easily manage LDAP Access Control Lists. C(olcAccess) attribute to easily manage LDAP Access Control Lists.
extends_documentation_fragment: extends_documentation_fragment:
- community.general.ldap.documentation - community.general.ldap.documentation
- community.general.attributes - community.general.attributes
"""
'''
EXAMPLES = r''' EXAMPLES = r"""
- name: Configure directory number 1 for example.com - name: Configure directory number 1 for example.com
community.general.ldap_attrs: community.general.ldap_attrs:
dn: olcDatabase={1}hdb,cn=config dn: olcDatabase={1}hdb,cn=config
@ -167,17 +151,17 @@ EXAMPLES = r'''
server_uri: ldap://localhost/ server_uri: ldap://localhost/
bind_dn: cn=admin,dc=example,dc=com bind_dn: cn=admin,dc=example,dc=com
bind_pw: password bind_pw: password
''' """
RETURN = r''' RETURN = r"""
modlist: modlist:
description: list of modified parameters description: List of modified parameters.
returned: success returned: success
type: list type: list
sample: sample:
- [2, "olcRootDN", ["cn=root,dc=example,dc=com"]] - [2, "olcRootDN", ["cn=root,dc=example,dc=com"]]
''' """
import traceback import traceback

View File

@ -11,21 +11,16 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: ldap_entry module: ldap_entry
short_description: Add or remove LDAP entries short_description: Add or remove LDAP entries
description: description:
- Add or remove LDAP entries. This module only asserts the existence or - Add or remove LDAP entries. This module only asserts the existence or non-existence of an LDAP entry, not its attributes. To assert the attribute
non-existence of an LDAP entry, not its attributes. To assert the values of an entry, see M(community.general.ldap_attrs).
attribute values of an entry, see M(community.general.ldap_attrs).
notes: notes:
- The default authentication settings will attempt to use a SASL EXTERNAL - The default authentication settings will attempt to use a SASL EXTERNAL bind over a UNIX domain socket. This works well with the default Ubuntu
bind over a UNIX domain socket. This works well with the default Ubuntu install for example, which includes a C(cn=peercred,cn=external,cn=auth) ACL rule allowing root to modify the server configuration. If you need
install for example, which includes a cn=peercred,cn=external,cn=auth ACL to use a simple bind to access your server, pass the credentials in O(bind_dn) and O(bind_pw).
rule allowing root to modify the server configuration. If you need to use
a simple bind to access your server, pass the credentials in O(bind_dn)
and O(bind_pw).
author: author:
- Jiri Tyr (@jtyr) - Jiri Tyr (@jtyr)
requirements: requirements:
@ -38,24 +33,18 @@ attributes:
options: options:
attributes: attributes:
description: description:
- If O(state=present), attributes necessary to create an entry. Existing - If O(state=present), attributes necessary to create an entry. Existing entries are never modified. To assert specific attribute values
entries are never modified. To assert specific attribute values on an on an existing entry, use M(community.general.ldap_attrs) module instead.
existing entry, use M(community.general.ldap_attrs) module instead. - Each attribute value can be a string for single-valued attributes or a list of strings for multi-valued attributes.
- Each attribute value can be a string for single-valued attributes or - If you specify values for this option in YAML, please note that you can improve readability for long string values by using YAML block
a list of strings for multi-valued attributes. modifiers as seen in the examples for this module.
- If you specify values for this option in YAML, please note that you can improve - Note that when using values that YAML/ansible-core interprets as other types, like V(yes), V(no) (booleans), or V(2.10) (float), make
readability for long string values by using YAML block modifiers as seen in the sure to quote them if these are meant to be strings. Otherwise the wrong values may be sent to LDAP.
examples for this module.
- Note that when using values that YAML/ansible-core interprets as other types,
like V(yes), V(no) (booleans), or V(2.10) (float), make sure to quote them if
these are meant to be strings. Otherwise the wrong values may be sent to LDAP.
type: dict type: dict
default: {} default: {}
objectClass: objectClass:
description: description:
- If O(state=present), value or list of values to use when creating - If O(state=present), value or list of values to use when creating the entry. It can either be a string or an actual list of strings.
the entry. It can either be a string or an actual list of
strings.
type: list type: list
elements: str elements: str
state: state:
@ -66,19 +55,17 @@ options:
type: str type: str
recursive: recursive:
description: description:
- If O(state=delete), a flag indicating whether a single entry or the - If O(state=delete), a flag indicating whether a single entry or the whole branch must be deleted.
whole branch must be deleted.
type: bool type: bool
default: false default: false
version_added: 4.6.0 version_added: 4.6.0
extends_documentation_fragment: extends_documentation_fragment:
- community.general.ldap.documentation - community.general.ldap.documentation
- community.general.attributes - community.general.attributes
"""
'''
EXAMPLES = """ EXAMPLES = r"""
- name: Make sure we have a parent entry for users - name: Make sure we have a parent entry for users
community.general.ldap_entry: community.general.ldap_entry:
dn: ou=users,dc=example,dc=com dn: ou=users,dc=example,dc=com
@ -143,7 +130,7 @@ EXAMPLES = """
""" """
RETURN = """ RETURN = r"""
# Default return values # Default return values
""" """

View File

@ -9,21 +9,16 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: ldap_passwd module: ldap_passwd
short_description: Set passwords in LDAP short_description: Set passwords in LDAP
description: description:
- Set a password for an LDAP entry. This module only asserts that - Set a password for an LDAP entry. This module only asserts that a given password is valid for a given entry. To assert the existence of an
a given password is valid for a given entry. To assert the entry, see M(community.general.ldap_entry).
existence of an entry, see M(community.general.ldap_entry).
notes: notes:
- The default authentication settings will attempt to use a SASL EXTERNAL - The default authentication settings will attempt to use a SASL EXTERNAL bind over a UNIX domain socket. This works well with the default Ubuntu
bind over a UNIX domain socket. This works well with the default Ubuntu install for example, which includes a C(cn=peercred,cn=external,cn=auth) ACL rule allowing root to modify the server configuration. If you
install for example, which includes a C(cn=peercred,cn=external,cn=auth) ACL need to use a simple bind to access your server, pass the credentials in O(bind_dn) and O(bind_pw).
rule allowing root to modify the server configuration. If you need to use
a simple bind to access your server, pass the credentials in O(bind_dn)
and O(bind_pw).
author: author:
- Keller Fuchs (@KellerFuchs) - Keller Fuchs (@KellerFuchs)
requirements: requirements:
@ -41,10 +36,9 @@ options:
extends_documentation_fragment: extends_documentation_fragment:
- community.general.ldap.documentation - community.general.ldap.documentation
- community.general.attributes - community.general.attributes
"""
''' EXAMPLES = r"""
EXAMPLES = """
- name: Set a password for the admin user - name: Set a password for the admin user
community.general.ldap_passwd: community.general.ldap_passwd:
dn: cn=admin,dc=example,dc=com dn: cn=admin,dc=example,dc=com
@ -60,9 +54,9 @@ EXAMPLES = """
admin: "{{ vault_secret }}" admin: "{{ vault_secret }}"
""" """
RETURN = """ RETURN = r"""
modlist: modlist:
description: list of modified parameters description: List of modified parameters.
returned: success returned: success
type: list type: list
sample: sample:

View File

@ -10,19 +10,15 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r""" DOCUMENTATION = r"""
---
module: ldap_search module: ldap_search
version_added: '0.2.0' version_added: '0.2.0'
short_description: Search for entries in a LDAP server short_description: Search for entries in a LDAP server
description: description:
- Return the results of an LDAP search. - Return the results of an LDAP search.
notes: notes:
- The default authentication settings will attempt to use a SASL EXTERNAL - The default authentication settings will attempt to use a SASL EXTERNAL bind over a UNIX domain socket. This works well with the default Ubuntu
bind over a UNIX domain socket. This works well with the default Ubuntu install for example, which includes a C(cn=peercred,cn=external,cn=auth) ACL rule allowing root to modify the server configuration. If you
install for example, which includes a C(cn=peercred,cn=external,cn=auth) ACL need to use a simple bind to access your server, pass the credentials in O(bind_dn) and O(bind_pw).
rule allowing root to modify the server configuration. If you need to use
a simple bind to access your server, pass the credentials in O(bind_dn)
and O(bind_pw).
author: author:
- Sebastian Pfahl (@eryx12o45) - Sebastian Pfahl (@eryx12o45)
requirements: requirements:
@ -55,30 +51,26 @@ options:
type: list type: list
elements: str elements: str
description: description:
- A list of attributes for limiting the result. Use an - A list of attributes for limiting the result. Use an actual list or a comma-separated string.
actual list or a comma-separated string.
schema: schema:
default: false default: false
type: bool type: bool
description: description:
- Set to V(true) to return the full attribute schema of entries, not - Set to V(true) to return the full attribute schema of entries, not their attribute values. Overrides O(attrs) when provided.
their attribute values. Overrides O(attrs) when provided.
page_size: page_size:
default: 0 default: 0
type: int type: int
description: description:
- The page size when performing a simple paged result search (RFC 2696). - The page size when performing a simple paged result search (RFC 2696). This setting can be tuned to reduce issues with timeouts and server
This setting can be tuned to reduce issues with timeouts and server limits. limits.
- Setting the page size to V(0) (default) disables paged searching. - Setting the page size to V(0) (default) disables paged searching.
version_added: 7.1.0 version_added: 7.1.0
base64_attributes: base64_attributes:
description: description:
- If provided, all attribute values returned that are listed in this option - If provided, all attribute values returned that are listed in this option will be Base64 encoded.
will be Base64 encoded. - If the special value V(*) appears in this list, all attributes will be Base64 encoded.
- If the special value V(*) appears in this list, all attributes will be - All other attribute values will be converted to UTF-8 strings. If they contain binary data, please note that invalid UTF-8 bytes will
Base64 encoded. be omitted.
- All other attribute values will be converted to UTF-8 strings. If they
contain binary data, please note that invalid UTF-8 bytes will be omitted.
type: list type: list
elements: str elements: str
version_added: 7.0.0 version_added: 7.0.0

View File

@ -9,12 +9,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: librato_annotation module: librato_annotation
short_description: Create an annotation in librato short_description: Create an annotation in librato
description: description:
- Create an annotation event on the given annotation stream :name. If the annotation stream does not exist, it will be created automatically - Create an annotation event on the given annotation stream :name. If the annotation stream does not exist, it will be created automatically.
author: "Seth Edwards (@Sedward)" author: "Seth Edwards (@Sedward)"
requirements: [] requirements: []
extends_documentation_fragment: extends_documentation_fragment:
@ -28,55 +27,55 @@ options:
user: user:
type: str type: str
description: description:
- Librato account username - Librato account username.
required: true required: true
api_key: api_key:
type: str type: str
description: description:
- Librato account api key - Librato account api key.
required: true required: true
name: name:
type: str type: str
description: description:
- The annotation stream name - The annotation stream name.
- If the annotation stream does not exist, it will be created automatically - If the annotation stream does not exist, it will be created automatically.
required: false required: false
title: title:
type: str type: str
description: description:
- The title of an annotation is a string and may contain spaces - The title of an annotation is a string and may contain spaces.
- The title should be a short, high-level summary of the annotation e.g. v45 Deployment - The title should be a short, high-level summary of the annotation for example V(v45 Deployment).
required: true required: true
source: source:
type: str type: str
description: description:
- A string which describes the originating source of an annotation when that annotation is tracked across multiple members of a population - A string which describes the originating source of an annotation when that annotation is tracked across multiple members of a population.
required: false required: false
description: description:
type: str type: str
description: description:
- The description contains extra metadata about a particular annotation - The description contains extra metadata about a particular annotation.
- The description should contain specifics on the individual annotation e.g. Deployed 9b562b2 shipped new feature foo! - The description should contain specifics on the individual annotation for example V(Deployed 9b562b2 shipped new feature foo!).
required: false required: false
start_time: start_time:
type: int type: int
description: description:
- The unix timestamp indicating the time at which the event referenced by this annotation started - The unix timestamp indicating the time at which the event referenced by this annotation started.
required: false required: false
end_time: end_time:
type: int type: int
description: description:
- The unix timestamp indicating the time at which the event referenced by this annotation ended - The unix timestamp indicating the time at which the event referenced by this annotation ended.
- For events that have a duration, this is a useful way to annotate the duration of the event - For events that have a duration, this is a useful way to annotate the duration of the event.
required: false required: false
links: links:
type: list type: list
elements: dict elements: dict
description: description:
- See examples - See examples.
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Create a simple annotation event with a source - name: Create a simple annotation event with a source
community.general.librato_annotation: community.general.librato_annotation:
user: user@example.com user: user@example.com
@ -105,7 +104,7 @@ EXAMPLES = '''
description: This is a detailed description of maintenance description: This is a detailed description of maintenance
start_time: 1395940006 start_time: 1395940006
end_time: 1395954406 end_time: 1395954406
''' """
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url from ansible.module_utils.urls import fetch_url

View File

@ -8,8 +8,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: linode module: linode
short_description: Manage instances on the Linode Public Cloud short_description: Manage instances on the Linode Public Cloud
description: description:
@ -24,8 +23,8 @@ attributes:
options: options:
state: state:
description: description:
- Indicate desired state of the resource - Indicate desired state of the resource.
choices: [ absent, active, deleted, present, restarted, started, stopped ] choices: [absent, active, deleted, present, restarted, started, stopped]
default: present default: present
type: str type: str
api_key: api_key:
@ -47,11 +46,9 @@ options:
default: '' default: ''
linode_id: linode_id:
description: description:
- Unique ID of a linode server. This value is read-only in the sense that - Unique ID of a linode server. This value is read-only in the sense that if you specify it on creation of a Linode it will not be used.
if you specify it on creation of a Linode it will not be used. The The Linode API generates these IDs and we can those generated value here to reference a Linode more specifically. This is useful for idempotence.
Linode API generates these IDs and we can those generated value here to aliases: [lid]
reference a Linode more specifically. This is useful for idempotence.
aliases: [ lid ]
type: int type: int
additional_disks: additional_disks:
description: description:
@ -109,17 +106,17 @@ options:
type: int type: int
plan: plan:
description: description:
- plan to use for the instance (Linode plan) - Plan to use for the instance (Linode plan).
type: int type: int
payment_term: payment_term:
description: description:
- payment term to use for the instance (payment term in months) - Payment term to use for the instance (payment term in months).
default: 1 default: 1
choices: [ 1, 12, 24 ] choices: [1, 12, 24]
type: int type: int
password: password:
description: description:
- root password to apply to a new server (auto generated if missing) - Root password to apply to a new server (auto generated if missing).
type: str type: str
private_ip: private_ip:
description: description:
@ -128,33 +125,33 @@ options:
type: bool type: bool
ssh_pub_key: ssh_pub_key:
description: description:
- SSH public key applied to root user - SSH public key applied to root user.
type: str type: str
swap: swap:
description: description:
- swap size in MB - Swap size in MB.
default: 512 default: 512
type: int type: int
distribution: distribution:
description: description:
- distribution to use for the instance (Linode Distribution) - Distribution to use for the instance (Linode Distribution).
type: int type: int
datacenter: datacenter:
description: description:
- datacenter to create an instance in (Linode Datacenter) - Datacenter to create an instance in (Linode Datacenter).
type: int type: int
kernel_id: kernel_id:
description: description:
- kernel to use for the instance (Linode Kernel) - Kernel to use for the instance (Linode Kernel).
type: int type: int
wait: wait:
description: description:
- wait for the instance to be in state V(running) before returning - Wait for the instance to be in state V(running) before returning.
type: bool type: bool
default: true default: true
wait_timeout: wait_timeout:
description: description:
- how long before wait gives up, in seconds - How long before wait gives up, in seconds.
default: 300 default: 300
type: int type: int
watchdog: watchdog:
@ -165,15 +162,14 @@ options:
requirements: requirements:
- linode-python - linode-python
author: author:
- Vincent Viallet (@zbal) - Vincent Viallet (@zbal)
notes: notes:
- Please note, linode-python does not have python 3 support. - Please note, linode-python does not have python 3 support.
- This module uses the now deprecated v3 of the Linode API. - This module uses the now deprecated v3 of the Linode API.
- Please review U(https://www.linode.com/api/linode) for determining the required parameters. - Please review U(https://www.linode.com/api/linode) for determining the required parameters.
''' """
EXAMPLES = '''
EXAMPLES = r"""
- name: Create a new Linode - name: Create a new Linode
community.general.linode: community.general.linode:
name: linode-test1 name: linode-test1
@ -275,7 +271,7 @@ EXAMPLES = '''
linode_id: "{{ linode_creation.instance.id }}" linode_id: "{{ linode_creation.instance.id }}"
state: restarted state: restarted
delegate_to: localhost delegate_to: localhost
''' """
import time import time
import traceback import traceback

View File

@ -8,8 +8,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: linode_v4 module: linode_v4
short_description: Manage instances on the Linode cloud short_description: Manage instances on the Linode cloud
description: Manage instances on the Linode cloud. description: Manage instances on the Linode cloud.
@ -18,9 +17,8 @@ requirements:
author: author:
- Luke Murphy (@decentral1se) - Luke Murphy (@decentral1se)
notes: notes:
- No Linode resizing is currently implemented. This module will, in time, - No Linode resizing is currently implemented. This module will, in time, replace the current Linode module which uses deprecated API bindings
replace the current Linode module which uses deprecated API bindings on the on the Linode side.
Linode side.
extends_documentation_fragment: extends_documentation_fragment:
- community.general.attributes - community.general.attributes
attributes: attributes:
@ -31,52 +29,44 @@ attributes:
options: options:
region: region:
description: description:
- The region of the instance. This is a required parameter only when - The region of the instance. This is a required parameter only when creating Linode instances. See U(https://www.linode.com/docs/api/regions/).
creating Linode instances. See
U(https://www.linode.com/docs/api/regions/).
type: str type: str
image: image:
description: description:
- The image of the instance. This is a required parameter only when - The image of the instance. This is a required parameter only when creating Linode instances.
creating Linode instances. See - See U(https://www.linode.com/docs/api/images/).
U(https://www.linode.com/docs/api/images/).
type: str type: str
type: type:
description: description:
- The type of the instance. This is a required parameter only when - The type of the instance. This is a required parameter only when creating Linode instances.
creating Linode instances. See - See U(https://www.linode.com/docs/api/linode-types/).
U(https://www.linode.com/docs/api/linode-types/).
type: str type: str
label: label:
description: description:
- The instance label. This label is used as the main determiner for - The instance label. This label is used as the main determiner for idempotence for the module and is therefore mandatory.
idempotence for the module and is therefore mandatory.
type: str type: str
required: true required: true
group: group:
description: description:
- The group that the instance should be marked under. Please note, that - The group that the instance should be marked under. Please note, that group labelling is deprecated but still supported. The encouraged
group labelling is deprecated but still supported. The encouraged
method for marking instances is to use tags. method for marking instances is to use tags.
type: str type: str
private_ip: private_ip:
description: description:
- If V(true), the created Linode will have private networking enabled and - If V(true), the created Linode will have private networking enabled and assigned a private IPv4 address.
assigned a private IPv4 address.
type: bool type: bool
default: false default: false
version_added: 3.0.0 version_added: 3.0.0
tags: tags:
description: description:
- The tags that the instance should be marked under. See - The tags that the instance should be marked under.
U(https://www.linode.com/docs/api/tags/). - See U(https://www.linode.com/docs/api/tags/).
type: list type: list
elements: str elements: str
root_pass: root_pass:
description: description:
- The password for the root user. If not specified, one will be - The password for the root user. If not specified, one will be generated. This generated password will be available in the task success
generated. This generated password will be available in the task JSON.
success JSON.
type: str type: str
authorized_keys: authorized_keys:
description: description:
@ -93,28 +83,26 @@ options:
required: true required: true
access_token: access_token:
description: description:
- The Linode API v4 access token. It may also be specified by exposing - The Linode API v4 access token. It may also be specified by exposing the E(LINODE_ACCESS_TOKEN) environment variable.
the E(LINODE_ACCESS_TOKEN) environment variable. See - See U(https://www.linode.com/docs/api#access-and-authentication).
U(https://www.linode.com/docs/api#access-and-authentication).
required: true required: true
type: str type: str
stackscript_id: stackscript_id:
description: description:
- The numeric ID of the StackScript to use when creating the instance. - The numeric ID of the StackScript to use when creating the instance.
See U(https://www.linode.com/docs/api/stackscripts/). - See U(https://www.linode.com/docs/api/stackscripts/).
type: int type: int
version_added: 1.3.0 version_added: 1.3.0
stackscript_data: stackscript_data:
description: description:
- An object containing arguments to any User Defined Fields present in - An object containing arguments to any User Defined Fields present in the StackScript used when creating the instance. Only valid when
the StackScript used when creating the instance. a O(stackscript_id) is provided.
Only valid when a stackscript_id is provided. - See U(https://www.linode.com/docs/api/stackscripts/).
See U(https://www.linode.com/docs/api/stackscripts/).
type: dict type: dict
version_added: 1.3.0 version_added: 1.3.0
''' """
EXAMPLES = """ EXAMPLES = r"""
- name: Create a new Linode. - name: Create a new Linode.
community.general.linode_v4: community.general.linode_v4:
label: new-linode label: new-linode
@ -135,7 +123,7 @@ EXAMPLES = """
state: absent state: absent
""" """
RETURN = """ RETURN = r"""
instance: instance:
description: The instance description in JSON serialized form. description: The instance description in JSON serialized form.
returned: Always. returned: Always.

View File

@ -8,8 +8,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
---
module: listen_ports_facts module: listen_ports_facts
author: author:
- Nathan Davison (@ndavison) - Nathan Davison (@ndavison)
@ -20,9 +19,8 @@ requirements:
- netstat or ss - netstat or ss
short_description: Gather facts on processes listening on TCP and UDP ports short_description: Gather facts on processes listening on TCP and UDP ports
notes: notes:
- | - C(ss) returns all processes for each listen address and port.
C(ss) returns all processes for each listen address and port. - This plugin will return each of them, so multiple entries for the same listen address and port are likely in results.
This plugin will return each of them, so multiple entries for the same listen address and port are likely in results.
extends_documentation_fragment: extends_documentation_fragment:
- community.general.attributes - community.general.attributes
- community.general.attributes.facts - community.general.attributes.facts
@ -31,7 +29,7 @@ options:
command: command:
description: description:
- Override which command to use for fetching listen ports. - Override which command to use for fetching listen ports.
- 'By default module will use first found supported command on the system (in alphanumerical order).' - By default module will use first found supported command on the system (in alphanumerical order).
type: str type: str
choices: choices:
- netstat - netstat
@ -40,14 +38,14 @@ options:
include_non_listening: include_non_listening:
description: description:
- Show both listening and non-listening sockets (for TCP this means established connections). - Show both listening and non-listening sockets (for TCP this means established connections).
- Adds the return values RV(ansible_facts.tcp_listen[].state), RV(ansible_facts.udp_listen[].state), - Adds the return values RV(ansible_facts.tcp_listen[].state), RV(ansible_facts.udp_listen[].state), RV(ansible_facts.tcp_listen[].foreign_address),
RV(ansible_facts.tcp_listen[].foreign_address), and RV(ansible_facts.udp_listen[].foreign_address) to the returned facts. and RV(ansible_facts.udp_listen[].foreign_address) to the returned facts.
type: bool type: bool
default: false default: false
version_added: 5.4.0 version_added: 5.4.0
''' """
EXAMPLES = r''' EXAMPLES = r"""
- name: Gather facts on listening ports - name: Gather facts on listening ports
community.general.listen_ports_facts: community.general.listen_ports_facts:
@ -77,11 +75,11 @@ EXAMPLES = r'''
community.general.listen_ports_facts: community.general.listen_ports_facts:
command: 'netstat' command: 'netstat'
include_non_listening: true include_non_listening: true
''' """
RETURN = r''' RETURN = r"""
ansible_facts: ansible_facts:
description: Dictionary containing details of TCP and UDP ports with listening servers description: Dictionary containing details of TCP and UDP ports with listening servers.
returned: always returned: always
type: complex type: complex
contains: contains:
@ -189,7 +187,7 @@ ansible_facts:
returned: always returned: always
type: str type: str
sample: "root" sample: "root"
''' """
import re import re
import platform import platform

View File

@ -9,13 +9,12 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: lldp module: lldp
requirements: [ lldpctl ] requirements: [lldpctl]
short_description: Get details reported by lldp short_description: Get details reported by LLDP
description: description:
- Reads data out of lldpctl - Reads data out of C(lldpctl).
extends_documentation_fragment: extends_documentation_fragment:
- community.general.attributes - community.general.attributes
attributes: attributes:
@ -26,15 +25,15 @@ attributes:
options: {} options: {}
author: "Andy Hill (@andyhky)" author: "Andy Hill (@andyhky)"
notes: notes:
- Requires lldpd running and lldp enabled on switches - Requires C(lldpd) running and LLDP enabled on switches.
''' """
EXAMPLES = ''' EXAMPLES = r"""
# Retrieve switch/port information # Retrieve switch/port information
- name: Gather information from lldp - name: Gather information from LLDP
community.general.lldp: community.general.lldp:
- name: Print each switch/port - name: Print each switch/port
ansible.builtin.debug: ansible.builtin.debug:
msg: "{{ lldp[item]['chassis']['name'] }} / {{ lldp[item]['port']['ifname'] }}" msg: "{{ lldp[item]['chassis']['name'] }} / {{ lldp[item]['port']['ifname'] }}"
with_items: "{{ lldp.keys() }}" with_items: "{{ lldp.keys() }}"
@ -43,8 +42,7 @@ EXAMPLES = '''
# ok: [10.13.0.22] => (item=eth2) => {"item": "eth2", "msg": "switch1.example.com / Gi0/24"} # ok: [10.13.0.22] => (item=eth2) => {"item": "eth2", "msg": "switch1.example.com / Gi0/24"}
# ok: [10.13.0.22] => (item=eth1) => {"item": "eth1", "msg": "switch2.example.com / Gi0/3"} # ok: [10.13.0.22] => (item=eth1) => {"item": "eth1", "msg": "switch2.example.com / Gi0/3"}
# ok: [10.13.0.22] => (item=eth0) => {"item": "eth0", "msg": "switch3.example.com / Gi0/3"} # ok: [10.13.0.22] => (item=eth0) => {"item": "eth0", "msg": "switch3.example.com / Gi0/3"}
"""
'''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule

View File

@ -8,12 +8,11 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: locale_gen module: locale_gen
short_description: Creates or removes locales short_description: Creates or removes locales
description: description:
- Manages locales by editing /etc/locale.gen and invoking locale-gen. - Manages locales by editing /etc/locale.gen and invoking C(locale-gen).
author: author:
- Augustus Kling (@AugustusKling) - Augustus Kling (@AugustusKling)
extends_documentation_fragment: extends_documentation_fragment:
@ -35,13 +34,13 @@ options:
type: str type: str
description: description:
- Whether the locale shall be present. - Whether the locale shall be present.
choices: [ absent, present ] choices: [absent, present]
default: present default: present
notes: notes:
- This module does not support RHEL-based systems. - This module does not support RHEL-based systems.
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Ensure a locale exists - name: Ensure a locale exists
community.general.locale_gen: community.general.locale_gen:
name: de_CH.UTF-8 name: de_CH.UTF-8
@ -53,7 +52,7 @@ EXAMPLES = '''
- en_GB.UTF-8 - en_GB.UTF-8
- nl_NL.UTF-8 - nl_NL.UTF-8
state: present state: present
''' """
import os import os
import re import re

View File

@ -9,13 +9,12 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: logentries module: logentries
author: "Ivan Vanderbyl (@ivanvanderbyl)" author: "Ivan Vanderbyl (@ivanvanderbyl)"
short_description: Module for tracking logs via logentries.com short_description: Module for tracking logs using U(logentries.com)
description: description:
- Sends logs to LogEntries in realtime - Sends logs to LogEntries in realtime.
extends_documentation_fragment: extends_documentation_fragment:
- community.general.attributes - community.general.attributes
attributes: attributes:
@ -27,31 +26,32 @@ options:
path: path:
type: str type: str
description: description:
- path to a log file - Path to a log file.
required: true required: true
state: state:
type: str type: str
description: description:
- following state of the log - Following state of the log.
choices: [ 'present', 'absent', 'followed', 'unfollowed' ] choices: ['present', 'absent', 'followed', 'unfollowed']
required: false required: false
default: present default: present
name: name:
type: str type: str
description: description:
- name of the log - Name of the log.
required: false required: false
logtype: logtype:
type: str type: str
description: description:
- type of the log - Type of the log.
required: false required: false
aliases: [type] aliases: [type]
notes: notes:
- Requires the LogEntries agent which can be installed following the instructions at logentries.com - Requires the LogEntries agent which can be installed following the instructions at U(logentries.com).
''' """
EXAMPLES = '''
EXAMPLES = r"""
- name: Track nginx logs - name: Track nginx logs
community.general.logentries: community.general.logentries:
path: /var/log/nginx/access.log path: /var/log/nginx/access.log
@ -62,7 +62,7 @@ EXAMPLES = '''
community.general.logentries: community.general.logentries:
path: /var/log/nginx/error.log path: /var/log/nginx/error.log
state: absent state: absent
''' """
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule

View File

@ -9,12 +9,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: logentries_msg module: logentries_msg
short_description: Send a message to logentries short_description: Send a message to logentries
description: description:
- Send a message to logentries - Send a message to logentries.
extends_documentation_fragment: extends_documentation_fragment:
- community.general.attributes - community.general.attributes
attributes: attributes:
@ -36,24 +35,24 @@ options:
api: api:
type: str type: str
description: description:
- API endpoint - API endpoint.
default: data.logentries.com default: data.logentries.com
port: port:
type: int type: int
description: description:
- API endpoint port - API endpoint port.
default: 80 default: 80
author: "Jimmy Tang (@jcftang) <jimmy_tang@rapid7.com>" author: "Jimmy Tang (@jcftang) <jimmy_tang@rapid7.com>"
''' """
RETURN = '''# ''' RETURN = """# """
EXAMPLES = ''' EXAMPLES = r"""
- name: Send a message to logentries - name: Send a message to logentries
community.general.logentries_msg: community.general.logentries_msg:
token=00000000-0000-0000-0000-000000000000 token: 00000000-0000-0000-0000-000000000000
msg="{{ ansible_hostname }}" msg: "{{ ansible_hostname }}"
''' """
import socket import socket

View File

@ -8,8 +8,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: logstash_plugin module: logstash_plugin
short_description: Manage Logstash plugins short_description: Manage Logstash plugins
description: description:
@ -50,11 +49,10 @@ options:
version: version:
type: str type: str
description: description:
- Specify plugin Version of the plugin to install. - Specify plugin Version of the plugin to install. If plugin exists with previous version, it will NOT be updated.
If plugin exists with previous version, it will NOT be updated. """
'''
EXAMPLES = ''' EXAMPLES = r"""
- name: Install Logstash beats input plugin - name: Install Logstash beats input plugin
community.general.logstash_plugin: community.general.logstash_plugin:
state: present state: present
@ -77,7 +75,7 @@ EXAMPLES = '''
name: logstash-input-beats name: logstash-input-beats
environment: environment:
LS_JAVA_OPTS: "-Xms256m -Xmx256m" LS_JAVA_OPTS: "-Xms256m -Xmx256m"
''' """
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule

View File

@ -9,10 +9,9 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
---
author: author:
- Alexander Bulimov (@abulimov) - Alexander Bulimov (@abulimov)
module: lvg module: lvg
short_description: Configure LVM volume groups short_description: Configure LVM volume groups
description: description:
@ -39,9 +38,8 @@ options:
elements: str elements: str
pesize: pesize:
description: description:
- "The size of the physical extent. O(pesize) must be a power of 2 of at least 1 sector - The size of the physical extent. O(pesize) must be a power of 2 of at least 1 sector (where the sector size is the largest sector size
(where the sector size is the largest sector size of the PVs currently used in the VG), of the PVs currently used in the VG), or at least 128KiB.
or at least 128KiB."
- O(pesize) can be optionally suffixed by a UNIT (k/K/m/M/g/G), default unit is megabyte. - O(pesize) can be optionally suffixed by a UNIT (k/K/m/M/g/G), default unit is megabyte.
type: str type: str
default: "4" default: "4"
@ -64,12 +62,11 @@ options:
state: state:
description: description:
- Control if the volume group exists and it's state. - Control if the volume group exists and it's state.
- The states V(active) and V(inactive) implies V(present) state. Added in 7.1.0 - The states V(active) and V(inactive) implies V(present) state. Added in 7.1.0.
- "If V(active) or V(inactive), the module manages the VG's logical volumes current state. - If V(active) or V(inactive), the module manages the VG's logical volumes current state. The module also handles the VG's autoactivation
The module also handles the VG's autoactivation state if supported state if supported unless when creating a volume group and the autoactivation option specified in O(vg_options).
unless when creating a volume group and the autoactivation option specified in O(vg_options)."
type: str type: str
choices: [ absent, present, active, inactive ] choices: [absent, present, active, inactive]
default: present default: present
force: force:
description: description:
@ -91,14 +88,14 @@ options:
default: false default: false
version_added: 7.1.0 version_added: 7.1.0
seealso: seealso:
- module: community.general.filesystem - module: community.general.filesystem
- module: community.general.lvol - module: community.general.lvol
- module: community.general.parted - module: community.general.parted
notes: notes:
- This module does not modify PE size for already present volume group. - This module does not modify PE size for already present volume group.
''' """
EXAMPLES = r''' EXAMPLES = r"""
- name: Create a volume group on top of /dev/sda1 with physical extent size = 32MB - name: Create a volume group on top of /dev/sda1 with physical extent size = 32MB
community.general.lvg: community.general.lvg:
vg: vg.services vg: vg.services
@ -154,7 +151,7 @@ EXAMPLES = r'''
pvs: /dev/sdb1,/dev/sdc5 pvs: /dev/sdb1,/dev/sdc5
reset_vg_uuid: true reset_vg_uuid: true
reset_pv_uuid: true reset_pv_uuid: true
''' """
import itertools import itertools
import os import os

View File

@ -8,8 +8,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
---
author: author:
- Laszlo Szomor (@lszomor) - Laszlo Szomor (@lszomor)
module: lvg_rename module: lvg_rename
@ -38,12 +37,12 @@ options:
type: str type: str
required: true required: true
seealso: seealso:
- module: community.general.lvg - module: community.general.lvg
notes: notes:
- This module does not modify VG renaming-related configurations like C(fstab) entries or boot parameters. - This module does not modify VG renaming-related configurations like C(fstab) entries or boot parameters.
''' """
EXAMPLES = r''' EXAMPLES = r"""
- name: Rename a VG by name - name: Rename a VG by name
community.general.lvg_rename: community.general.lvg_rename:
vg: vg_orig_name vg: vg_orig_name
@ -53,7 +52,7 @@ EXAMPLES = r'''
community.general.lvg_rename: community.general.lvg_rename:
vg_uuid: SNgd0Q-rPYa-dPB8-U1g6-4WZI-qHID-N7y9Vj vg_uuid: SNgd0Q-rPYa-dPB8-U1g6-4WZI-qHID-N7y9Vj
vg_new: vg_new_name vg_new: vg_new_name
''' """
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule

View File

@ -8,8 +8,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
author: author:
- Jeroen Hoekx (@jhoekx) - Jeroen Hoekx (@jhoekx)
- Alexander Bulimov (@abulimov) - Alexander Bulimov (@abulimov)
@ -39,21 +38,17 @@ options:
size: size:
type: str type: str
description: description:
- The size of the logical volume, according to lvcreate(8) --size, by - The size of the logical volume, according to lvcreate(8) C(--size), by default in megabytes or optionally with one of [bBsSkKmMgGtTpPeE]
default in megabytes or optionally with one of [bBsSkKmMgGtTpPeE] units; or units; or according to lvcreate(8) --extents as a percentage of [VG|PVS|FREE|ORIGIN]; Float values must begin with a digit.
according to lvcreate(8) --extents as a percentage of [VG|PVS|FREE|ORIGIN]; - When resizing, apart from specifying an absolute size you may, according to lvextend(8)|lvreduce(8) C(--size), specify the amount to extend
Float values must begin with a digit. the logical volume with the prefix V(+) or the amount to reduce the logical volume by with prefix V(-).
- When resizing, apart from specifying an absolute size you may, according to
lvextend(8)|lvreduce(8) C(--size), specify the amount to extend the logical volume with
the prefix V(+) or the amount to reduce the logical volume by with prefix V(-).
- Resizing using V(+) or V(-) was not supported prior to community.general 3.0.0. - Resizing using V(+) or V(-) was not supported prior to community.general 3.0.0.
- Please note that when using V(+), V(-), or percentage of FREE, the module is B(not idempotent). - Please note that when using V(+), V(-), or percentage of FREE, the module is B(not idempotent).
state: state:
type: str type: str
description: description:
- Control if the logical volume exists. If V(present) and the - Control if the logical volume exists. If V(present) and the volume does not already exist then the O(size) option is required.
volume does not already exist then the O(size) option is required. choices: [absent, present]
choices: [ absent, present ]
default: present default: present
active: active:
description: description:
@ -62,8 +57,7 @@ options:
default: true default: true
force: force:
description: description:
- Shrink or remove operations of volumes requires this switch. Ensures that - Shrink or remove operations of volumes requires this switch. Ensures that that filesystems get never corrupted/destroyed by mistake.
that filesystems get never corrupted/destroyed by mistake.
type: bool type: bool
default: false default: false
opts: opts:
@ -91,15 +85,14 @@ options:
resizefs: resizefs:
description: description:
- Resize the underlying filesystem together with the logical volume. - Resize the underlying filesystem together with the logical volume.
- Supported for C(ext2), C(ext3), C(ext4), C(reiserfs) and C(XFS) filesystems. - Supported for C(ext2), C(ext3), C(ext4), C(reiserfs) and C(XFS) filesystems. Attempts to resize other filesystem types will fail.
Attempts to resize other filesystem types will fail.
type: bool type: bool
default: false default: false
notes: notes:
- You must specify lv (when managing the state of logical volumes) or thinpool (when managing a thin provisioned volume). - You must specify lv (when managing the state of logical volumes) or thinpool (when managing a thin provisioned volume).
''' """
EXAMPLES = ''' EXAMPLES = r"""
- name: Create a logical volume of 512m - name: Create a logical volume of 512m
community.general.lvol: community.general.lvol:
vg: firefly vg: firefly
@ -233,7 +226,7 @@ EXAMPLES = '''
lv: test lv: test
thinpool: testpool thinpool: testpool
size: 128g size: 128g
''' """
import re import re
import shlex import shlex

View File

@ -9,8 +9,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r''' DOCUMENTATION = r"""
---
module: lxc_container module: lxc_container
short_description: Manage LXC Containers short_description: Manage LXC Containers
description: description:
@ -57,7 +56,7 @@ options:
lv_name: lv_name:
description: description:
- Name of the logical volume, defaults to the container name. - Name of the logical volume, defaults to the container name.
- If not specified, it defaults to C($CONTAINER_NAME). - If not specified, it defaults to E(CONTAINER_NAME).
type: str type: str
vg_name: vg_name:
description: description:
@ -144,8 +143,7 @@ options:
- bzip2 - bzip2
- none - none
description: description:
- Type of compression to use when creating an archive of a running - Type of compression to use when creating an archive of a running container.
container.
type: str type: str
default: gzip default: gzip
state: state:
@ -158,11 +156,9 @@ options:
- clone - clone
description: description:
- Define the state of a container. - Define the state of a container.
- If you clone a container using O(clone_name) the newly cloned - If you clone a container using O(clone_name) the newly cloned container created in a stopped state.
container created in a stopped state. - The running container will be stopped while the clone operation is happening and upon completion of the clone the original container state
- The running container will be stopped while the clone operation is will be restored.
happening and upon completion of the clone the original container
state will be restored.
type: str type: str
default: started default: started
container_config: container_config:
@ -175,27 +171,18 @@ requirements:
- 'python3 >= 3.5 # OS Package' - 'python3 >= 3.5 # OS Package'
- 'python3-lxc # OS Package' - 'python3-lxc # OS Package'
notes: notes:
- Containers must have a unique name. If you attempt to create a container - Containers must have a unique name. If you attempt to create a container with a name that already exists in the users namespace the module
with a name that already exists in the users namespace the module will will simply return as "unchanged".
simply return as "unchanged". - The O(container_command) can be used with any state except V(absent). If used with state V(stopped) the container will be V(started), the
- The O(container_command) can be used with any state except V(absent). If command executed, and then the container V(stopped) again. Likewise if O(state=stopped) and the container does not exist it will be first
used with state V(stopped) the container will be V(started), the command created, V(started), the command executed, and then V(stopped). If you use a C(|) in the variable you can use common script formatting within
executed, and then the container V(stopped) again. Likewise if O(state=stopped) the variable itself. The O(container_command) option will always execute as C(bash). When using O(container_command), a log file is created in
and the container does not exist it will be first created, the C(/tmp/) directory which contains both C(stdout) and C(stderr) of any command executed.
V(started), the command executed, and then V(stopped). If you use a "|" - If O(archive=true) the system will attempt to create a compressed tarball of the running container. The O(archive) option supports LVM backed
in the variable you can use common script formatting within the variable containers and will create a snapshot of the running container when creating the archive.
itself. The O(container_command) option will always execute as BASH. - If your distro does not have a package for C(python3-lxc), which is a requirement for this module, it can be installed from source at
When using O(container_command), a log file is created in the C(/tmp/) directory U(https://github.com/lxc/python3-lxc) or installed using C(pip install lxc).
which contains both C(stdout) and C(stderr) of any command executed. """
- If O(archive=true) the system will attempt to create a compressed
tarball of the running container. The O(archive) option supports LVM backed
containers and will create a snapshot of the running container when
creating the archive.
- If your distro does not have a package for C(python3-lxc), which is a
requirement for this module, it can be installed from source at
U(https://github.com/lxc/python3-lxc) or installed via pip using the
package name C(lxc).
'''
EXAMPLES = r""" EXAMPLES = r"""
- name: Create a started container - name: Create a started container
@ -382,42 +369,42 @@ EXAMPLES = r"""
RETURN = r""" RETURN = r"""
lxc_container: lxc_container:
description: container information description: Container information.
returned: success returned: success
type: complex type: complex
contains: contains:
name: name:
description: name of the lxc container description: Name of the lxc container.
returned: success returned: success
type: str type: str
sample: test_host sample: test_host
init_pid: init_pid:
description: pid of the lxc init process description: Pid of the lxc init process.
returned: success returned: success
type: int type: int
sample: 19786 sample: 19786
interfaces: interfaces:
description: list of the container's network interfaces description: List of the container's network interfaces.
returned: success returned: success
type: list type: list
sample: [ "eth0", "lo" ] sample: ["eth0", "lo"]
ips: ips:
description: list of ips description: List of ips.
returned: success returned: success
type: list type: list
sample: [ "10.0.3.3" ] sample: ["10.0.3.3"]
state: state:
description: resulting state of the container description: Resulting state of the container.
returned: success returned: success
type: str type: str
sample: "running" sample: "running"
archive: archive:
description: resulting state of the container description: Resulting state of the container.
returned: success, when archive is true returned: success, when archive is true
type: str type: str
sample: "/tmp/test-container-config.tar" sample: "/tmp/test-container-config.tar"
clone: clone:
description: if the container was cloned description: If the container was cloned.
returned: success, when clone_name is specified returned: success, when clone_name is specified
type: bool type: bool
sample: true sample: true

View File

@ -8,16 +8,14 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
author: author:
- Naval Patel (@navalkp) - Naval Patel (@navalkp)
- Prashant Bhosale (@prabhosa) - Prashant Bhosale (@prabhosa)
module: lxca_cmms module: lxca_cmms
short_description: Custom module for lxca cmms inventory utility short_description: Custom module for lxca cmms inventory utility
description: description:
- This module returns/displays a inventory details of cmms - This module returns/displays a inventory details of cmms.
attributes: attributes:
check_mode: check_mode:
support: none support: none
@ -26,13 +24,11 @@ attributes:
options: options:
uuid: uuid:
description: description: UUID of device, this is string with length greater than 16.
uuid of device, this is string with length greater than 16.
type: str type: str
command_options: command_options:
description: description: Options to filter nodes information.
options to filter nodes information
default: cmms default: cmms
choices: choices:
- cmms - cmms
@ -41,17 +37,15 @@ options:
type: str type: str
chassis: chassis:
description: description: UUID of chassis, this is string with length greater than 16.
uuid of chassis, this is string with length greater than 16.
type: str type: str
extends_documentation_fragment: extends_documentation_fragment:
- community.general.lxca_common - community.general.lxca_common
- community.general.attributes - community.general.attributes
"""
''' EXAMPLES = r"""
EXAMPLES = '''
# get all cmms info # get all cmms info
- name: Get nodes data from LXCA - name: Get nodes data from LXCA
community.general.lxca_cmms: community.general.lxca_cmms:
@ -76,12 +70,11 @@ EXAMPLES = '''
auth_url: "https://10.243.15.168" auth_url: "https://10.243.15.168"
chassis: "3C737AA5E31640CE949B10C129A8B01F" chassis: "3C737AA5E31640CE949B10C129A8B01F"
command_options: cmms_by_chassis_uuid command_options: cmms_by_chassis_uuid
"""
''' RETURN = r"""
RETURN = r'''
result: result:
description: cmms detail from lxca description: Cmms detail from lxca.
returned: success returned: success
type: dict type: dict
sample: sample:
@ -97,7 +90,7 @@ result:
uuid: '223D2C88C8FD11E4947B6EAE8B4BDCDF' uuid: '223D2C88C8FD11E4947B6EAE8B4BDCDF'
# bunch of properties # bunch of properties
# Multiple cmms details # Multiple cmms details
''' """
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule

View File

@ -8,16 +8,14 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
author: author:
- Naval Patel (@navalkp) - Naval Patel (@navalkp)
- Prashant Bhosale (@prabhosa) - Prashant Bhosale (@prabhosa)
module: lxca_nodes module: lxca_nodes
short_description: Custom module for lxca nodes inventory utility short_description: Custom module for lxca nodes inventory utility
description: description:
- This module returns/displays a inventory details of nodes - This module returns/displays a inventory details of nodes.
attributes: attributes:
check_mode: check_mode:
support: none support: none
@ -26,13 +24,11 @@ attributes:
options: options:
uuid: uuid:
description: description: UUID of device, this is string with length greater than 16.
uuid of device, this is string with length greater than 16.
type: str type: str
command_options: command_options:
description: description: Options to filter nodes information.
options to filter nodes information
default: nodes default: nodes
choices: choices:
- nodes - nodes
@ -43,17 +39,15 @@ options:
type: str type: str
chassis: chassis:
description: description: UUID of chassis, this is string with length greater than 16.
uuid of chassis, this is string with length greater than 16.
type: str type: str
extends_documentation_fragment: extends_documentation_fragment:
- community.general.lxca_common - community.general.lxca_common
- community.general.attributes - community.general.attributes
"""
''' EXAMPLES = r"""
EXAMPLES = '''
# get all nodes info # get all nodes info
- name: Get nodes data from LXCA - name: Get nodes data from LXCA
community.general.lxca_nodes: community.general.lxca_nodes:
@ -95,12 +89,11 @@ EXAMPLES = '''
login_password: Password login_password: Password
auth_url: "https://10.243.15.168" auth_url: "https://10.243.15.168"
command_options: nodes_status_unmanaged command_options: nodes_status_unmanaged
"""
''' RETURN = r"""
RETURN = r'''
result: result:
description: nodes detail from lxca description: Nodes detail from lxca.
returned: always returned: always
type: dict type: dict
sample: sample:
@ -116,7 +109,7 @@ result:
uuid: '223D2C88C8FD11E4947B6EAE8B4BDCDF' uuid: '223D2C88C8FD11E4947B6EAE8B4BDCDF'
# bunch of properties # bunch of properties
# Multiple nodes details # Multiple nodes details
''' """
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule

View File

@ -9,8 +9,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: lxd_container module: lxd_container
short_description: Manage LXD instances short_description: Manage LXD instances
description: description:
@ -33,32 +32,30 @@ options:
required: true required: true
project: project:
description: description:
- 'Project of an instance. - Project of an instance.
See U(https://documentation.ubuntu.com/lxd/en/latest/projects/).' - See U(https://documentation.ubuntu.com/lxd/en/latest/projects/).
required: false required: false
type: str type: str
version_added: 4.8.0 version_added: 4.8.0
architecture: architecture:
description: description:
- 'The architecture for the instance (for example V(x86_64) or V(i686)). - The architecture for the instance (for example V(x86_64) or V(i686)).
See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get).' - See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get).
type: str type: str
required: false required: false
config: config:
description: description:
- 'The config for the instance (for example V({"limits.cpu": "2"})). - 'The config for the instance (for example V({"limits.cpu": "2"})).
See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get).' - See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get).'
- If the instance already exists and its "config" values in metadata - If the instance already exists and its "config" values in metadata obtained from the LXD API
obtained from the LXD API U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get) U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get)
are different, then this module tries to apply the configurations are different, then this module tries to apply the configurations U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_put).
U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_put).
- The keys starting with C(volatile.) are ignored for this comparison when O(ignore_volatile_options=true). - The keys starting with C(volatile.) are ignored for this comparison when O(ignore_volatile_options=true).
type: dict type: dict
required: false required: false
ignore_volatile_options: ignore_volatile_options:
description: description:
- If set to V(true), options starting with C(volatile.) are ignored. As a result, - If set to V(true), options starting with C(volatile.) are ignored. As a result, they are reapplied for each execution.
they are reapplied for each execution.
- This default behavior can be changed by setting this option to V(false). - This default behavior can be changed by setting this option to V(false).
- The default value changed from V(true) to V(false) in community.general 6.0.0. - The default value changed from V(true) to V(false) in community.general 6.0.0.
type: bool type: bool
@ -72,23 +69,21 @@ options:
elements: str elements: str
devices: devices:
description: description:
- 'The devices for the instance - 'The devices for the instance (for example V({ "rootfs": { "path": "/dev/kvm", "type": "unix-char" }})).
(for example V({ "rootfs": { "path": "/dev/kvm", "type": "unix-char" }})). - See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get).'
See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get).'
type: dict type: dict
required: false required: false
ephemeral: ephemeral:
description: description:
- Whether or not the instance is ephemeral (for example V(true) or V(false)). - Whether or not the instance is ephemeral (for example V(true) or V(false)).
See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get). - See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/instances/instance_get).
required: false required: false
type: bool type: bool
source: source:
description: description:
- 'The source for the instance - 'The source for the instance (for example V({ "type": "image", "mode": "pull", "server": "https://cloud-images.ubuntu.com/releases/",
(for example V({ "type": "image", "mode": "pull", "server": "https://cloud-images.ubuntu.com/releases/",
"protocol": "simplestreams", "alias": "22.04" })).' "protocol": "simplestreams", "alias": "22.04" })).'
- 'See U(https://documentation.ubuntu.com/lxd/en/latest/api/) for complete API documentation.' - See U(https://documentation.ubuntu.com/lxd/en/latest/api/) for complete API documentation.
- 'Note that C(protocol) accepts two choices: V(lxd) or V(simplestreams).' - 'Note that C(protocol) accepts two choices: V(lxd) or V(simplestreams).'
required: false required: false
type: dict type: dict
@ -106,18 +101,16 @@ options:
type: str type: str
target: target:
description: description:
- For cluster deployments. Will attempt to create an instance on a target node. - For cluster deployments. Will attempt to create an instance on a target node. If the instance exists elsewhere in a cluster, then it will
If the instance exists elsewhere in a cluster, then it will not be replaced or moved. not be replaced or moved. The name should respond to same name of the node you see in C(lxc cluster list).
The name should respond to same name of the node you see in C(lxc cluster list).
type: str type: str
required: false required: false
version_added: 1.0.0 version_added: 1.0.0
timeout: timeout:
description: description:
- A timeout for changing the state of the instance. - A timeout for changing the state of the instance.
- This is also used as a timeout for waiting until IPv4 addresses - This is also used as a timeout for waiting until IPv4 addresses are set to the all network interfaces in the instance after starting or
are set to the all network interfaces in the instance after restarting.
starting or restarting.
required: false required: false
default: 30 default: 30
type: int type: int
@ -133,23 +126,20 @@ options:
version_added: 4.1.0 version_added: 4.1.0
wait_for_ipv4_addresses: wait_for_ipv4_addresses:
description: description:
- If this is V(true), the C(lxd_container) waits until IPv4 addresses - If this is V(true), the C(lxd_container) waits until IPv4 addresses are set to the all network interfaces in the instance after starting
are set to the all network interfaces in the instance after or restarting.
starting or restarting.
required: false required: false
default: false default: false
type: bool type: bool
wait_for_container: wait_for_container:
description: description:
- If set to V(true), the tasks will wait till the task reports a - If set to V(true), the tasks will wait till the task reports a success status when performing container operations.
success status when performing container operations.
default: false default: false
type: bool type: bool
version_added: 4.4.0 version_added: 4.4.0
force_stop: force_stop:
description: description:
- If this is V(true), the C(lxd_container) forces to stop the instance - If this is V(true), the C(lxd_container) forces to stop the instance when it stops or restarts the instance.
when it stops or restarts the instance.
required: false required: false
default: false default: false
type: bool type: bool
@ -170,47 +160,38 @@ options:
- The client certificate key file path. - The client certificate key file path.
- If not specified, it defaults to C(${HOME}/.config/lxc/client.key). - If not specified, it defaults to C(${HOME}/.config/lxc/client.key).
required: false required: false
aliases: [ key_file ] aliases: [key_file]
type: path type: path
client_cert: client_cert:
description: description:
- The client certificate file path. - The client certificate file path.
- If not specified, it defaults to C(${HOME}/.config/lxc/client.crt). - If not specified, it defaults to C(${HOME}/.config/lxc/client.crt).
required: false required: false
aliases: [ cert_file ] aliases: [cert_file]
type: path type: path
trust_password: trust_password:
description: description:
- The client trusted password. - The client trusted password.
- 'You need to set this password on the LXD server before - 'You need to set this password on the LXD server before running this module using the following command: C(lxc config set core.trust_password
running this module using the following command: <some random password>). See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/).'
C(lxc config set core.trust_password <some random password>). - If trust_password is set, this module send a request for authentication before sending any requests.
See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/).'
- If trust_password is set, this module send a request for
authentication before sending any requests.
required: false required: false
type: str type: str
notes: notes:
- Instances can be a container or a virtual machine, both of them must have unique name. If you attempt to create an instance - Instances can be a container or a virtual machine, both of them must have unique name. If you attempt to create an instance with a name that
with a name that already existed in the users namespace the module will already existed in the users namespace the module will simply return as "unchanged".
simply return as "unchanged". - There are two ways to run commands inside a container or virtual machine, using the command module or using the ansible lxd connection plugin
- There are two ways to run commands inside a container or virtual machine, using the command bundled in Ansible >= 2.1, the later requires python to be installed in the instance which can be done with the command module.
module or using the ansible lxd connection plugin bundled in Ansible >= - You can copy a file from the host to the instance with the Ansible M(ansible.builtin.copy) and M(ansible.builtin.template) module and the
2.1, the later requires python to be installed in the instance which can P(community.general.lxd#connection) connection plugin. See the example below.
be done with the command module. - You can copy a file in the created instance to the localhost with C(command=lxc file pull instance_name/dir/filename filename). See the first
- You can copy a file from the host to the instance example below.
with the Ansible M(ansible.builtin.copy) and M(ansible.builtin.template) module - Linuxcontainers.org has phased out LXC/LXD support with March 2024
and the P(community.general.lxd#connection) connection plugin.
See the example below.
- You can copy a file in the created instance to the localhost
with C(command=lxc file pull instance_name/dir/filename filename).
See the first example below.
- linuxcontainers.org has phased out LXC/LXD support with March 2024
(U(https://discuss.linuxcontainers.org/t/important-notice-for-lxd-users-image-server/18479)). (U(https://discuss.linuxcontainers.org/t/important-notice-for-lxd-users-image-server/18479)).
Currently only Ubuntu is still providing images. Currently only Ubuntu is still providing images.
''' """
EXAMPLES = ''' EXAMPLES = r"""
# An example for creating a Ubuntu container and install python # An example for creating a Ubuntu container and install python
- hosts: localhost - hosts: localhost
connection: local connection: local
@ -400,12 +381,12 @@ EXAMPLES = '''
protocol: simplestreams protocol: simplestreams
type: image type: image
mode: pull mode: pull
server: [...] # URL to the image server server: ['...'] # URL to the image server
alias: debian/11 alias: debian/11
timeout: 600 timeout: 600
''' """
RETURN = ''' RETURN = r"""
addresses: addresses:
description: Mapping from the network device name to a list of IPv4 addresses in the instance. description: Mapping from the network device name to a list of IPv4 addresses in the instance.
returned: when state is started or restarted returned: when state is started or restarted
@ -426,7 +407,8 @@ actions:
returned: success returned: success
type: list type: list
sample: ["create", "start"] sample: ["create", "start"]
''' """
import copy import copy
import datetime import datetime
import os import os

View File

@ -9,12 +9,11 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: lxd_profile module: lxd_profile
short_description: Manage LXD profiles short_description: Manage LXD profiles
description: description:
- Management of LXD profiles - Management of LXD profiles.
author: "Hiroaki Nakamura (@hnakamur)" author: "Hiroaki Nakamura (@hnakamur)"
extends_documentation_fragment: extends_documentation_fragment:
- community.general.attributes - community.general.attributes
@ -31,8 +30,7 @@ options:
type: str type: str
project: project:
description: description:
- 'Project of a profile. - Project of a profile. See U(https://documentation.ubuntu.com/lxd/en/latest/projects/).
See U(https://documentation.ubuntu.com/lxd/en/latest/projects/).'
type: str type: str
required: false required: false
version_added: 4.8.0 version_added: 4.8.0
@ -42,36 +40,30 @@ options:
type: str type: str
config: config:
description: description:
- 'The config for the instance (e.g. {"limits.memory": "4GB"}). - 'The config for the instance (for example V({"limits.memory": "4GB"})).
See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_get).' - See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_get).'
- If the profile already exists and its "config" value in metadata - If the profile already exists and its C(config) value in metadata obtained from GET /1.0/profiles/<name>
obtained from
GET /1.0/profiles/<name>
U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_get) U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_get)
are different, then this module tries to apply the configurations are different, then this module tries to apply the configurations U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_put).
U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_put). - Not all config values are supported to apply the existing profile. Maybe you need to delete and recreate a profile.
- Not all config values are supported to apply the existing profile.
Maybe you need to delete and recreate a profile.
required: false required: false
type: dict type: dict
devices: devices:
description: description:
- 'The devices for the profile - 'The devices for the profile (for example V({"rootfs": {"path": "/dev/kvm", "type": "unix-char"})).
(e.g. {"rootfs": {"path": "/dev/kvm", "type": "unix-char"}). - See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_get).'
See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_get).'
required: false required: false
type: dict type: dict
new_name: new_name:
description: description:
- A new name of a profile. - A new name of a profile.
- If this parameter is specified a profile will be renamed to this name. - If this parameter is specified a profile will be renamed to this name.
See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_post). - See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/profiles/profile_post).
required: false required: false
type: str type: str
merge_profile: merge_profile:
description: description:
- Merge the configuration of the present profile with the new desired configuration, - Merge the configuration of the present profile with the new desired configuration, instead of replacing it.
instead of replacing it.
required: false required: false
default: false default: false
type: bool type: bool
@ -102,33 +94,29 @@ options:
- The client certificate key file path. - The client certificate key file path.
- If not specified, it defaults to C($HOME/.config/lxc/client.key). - If not specified, it defaults to C($HOME/.config/lxc/client.key).
required: false required: false
aliases: [ key_file ] aliases: [key_file]
type: path type: path
client_cert: client_cert:
description: description:
- The client certificate file path. - The client certificate file path.
- If not specified, it defaults to C($HOME/.config/lxc/client.crt). - If not specified, it defaults to C($HOME/.config/lxc/client.crt).
required: false required: false
aliases: [ cert_file ] aliases: [cert_file]
type: path type: path
trust_password: trust_password:
description: description:
- The client trusted password. - The client trusted password.
- You need to set this password on the LXD server before - You need to set this password on the LXD server before running this module using the following command. lxc config set core.trust_password
running this module using the following command. <some random password> See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/).
lxc config set core.trust_password <some random password> - If trust_password is set, this module send a request for authentication before sending any requests.
See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/)
- If trust_password is set, this module send a request for
authentication before sending any requests.
required: false required: false
type: str type: str
notes: notes:
- Profiles must have a unique name. If you attempt to create a profile - Profiles must have a unique name. If you attempt to create a profile with a name that already existed in the users namespace the module will
with a name that already existed in the users namespace the module will
simply return as "unchanged". simply return as "unchanged".
''' """
EXAMPLES = ''' EXAMPLES = r"""
# An example for creating a profile # An example for creating a profile
- hosts: localhost - hosts: localhost
connection: local connection: local
@ -214,11 +202,11 @@ EXAMPLES = '''
name: macvlan name: macvlan
new_name: macvlan2 new_name: macvlan2
state: present state: present
''' """
RETURN = ''' RETURN = r"""
old_state: old_state:
description: The old state of the profile description: The old state of the profile.
returned: success returned: success
type: str type: str
sample: "absent" sample: "absent"
@ -232,7 +220,7 @@ actions:
returned: success returned: success
type: list type: list
sample: ["create"] sample: ["create"]
''' """
import os import os
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule

View File

@ -7,8 +7,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r"""
---
module: lxd_project module: lxd_project
short_description: Manage LXD projects short_description: Manage LXD projects
version_added: 4.8.0 version_added: 4.8.0
@ -35,25 +34,22 @@ options:
config: config:
description: description:
- 'The config for the project (for example V({"features.profiles": "true"})). - 'The config for the project (for example V({"features.profiles": "true"})).
See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_get).' - See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_get).'
- If the project already exists and its "config" value in metadata - If the project already exists and its "config" value in metadata obtained from C(GET /1.0/projects/<name>)
obtained from
C(GET /1.0/projects/<name>)
U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_get) U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_get)
are different, then this module tries to apply the configurations are different, then this module tries to apply the configurations U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_put).
U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_put).
type: dict type: dict
new_name: new_name:
description: description:
- A new name of a project. - A new name of a project.
- If this parameter is specified a project will be renamed to this name. - If this parameter is specified a project will be renamed to this name.
See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_post). - See U(https://documentation.ubuntu.com/lxd/en/latest/api/#/projects/project_post).
required: false required: false
type: str type: str
merge_project: merge_project:
description: description:
- Merge the configuration of the present project with the new desired configuration, - Merge the configuration of the present project with the new desired configuration, instead of replacing it. If configuration is the same
instead of replacing it. If configuration is the same after merged, no change will be made. after merged, no change will be made.
required: false required: false
default: false default: false
type: bool type: bool
@ -83,33 +79,29 @@ options:
- The client certificate key file path. - The client certificate key file path.
- If not specified, it defaults to C($HOME/.config/lxc/client.key). - If not specified, it defaults to C($HOME/.config/lxc/client.key).
required: false required: false
aliases: [ key_file ] aliases: [key_file]
type: path type: path
client_cert: client_cert:
description: description:
- The client certificate file path. - The client certificate file path.
- If not specified, it defaults to C($HOME/.config/lxc/client.crt). - If not specified, it defaults to C($HOME/.config/lxc/client.crt).
required: false required: false
aliases: [ cert_file ] aliases: [cert_file]
type: path type: path
trust_password: trust_password:
description: description:
- The client trusted password. - The client trusted password.
- 'You need to set this password on the LXD server before - 'You need to set this password on the LXD server before running this module using the following command: C(lxc config set core.trust_password
running this module using the following command: <some random password>) See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/).'
C(lxc config set core.trust_password <some random password>) - If O(trust_password) is set, this module send a request for authentication before sending any requests.
See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/).'
- If O(trust_password) is set, this module send a request for
authentication before sending any requests.
required: false required: false
type: str type: str
notes: notes:
- Projects must have a unique name. If you attempt to create a project - Projects must have a unique name. If you attempt to create a project with a name that already existed in the users namespace the module will
with a name that already existed in the users namespace the module will
simply return as "unchanged". simply return as "unchanged".
''' """
EXAMPLES = ''' EXAMPLES = r"""
# An example for creating a project # An example for creating a project
- hosts: localhost - hosts: localhost
connection: local connection: local
@ -132,9 +124,9 @@ EXAMPLES = '''
state: present state: present
config: {} config: {}
description: my new project description: my new project
''' """
RETURN = ''' RETURN = r"""
old_state: old_state:
description: The old state of the project. description: The old state of the project.
returned: success returned: success
@ -184,7 +176,7 @@ actions:
type: list type: list
elements: str elements: str
sample: ["create"] sample: ["create"]
''' """
from ansible_collections.community.general.plugins.module_utils.lxd import ( from ansible_collections.community.general.plugins.module_utils.lxd import (
LXDClient, LXDClientException, default_key_file, default_cert_file LXDClient, LXDClientException, default_key_file, default_cert_file