Fix lxd_container and lxd_profile document to be rendered properly

pull/18777/head
Hiroaki Nakamura 9 years ago committed by Matt Clay
parent a06179e08b
commit 04d049cee9

@ -19,7 +19,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
DOCUMENTATION = """ DOCUMENTATION = '''
--- ---
module: lxd_container module: lxd_container
short_description: Manage LXD Containers short_description: Manage LXD Containers
@ -35,17 +35,16 @@ options:
architecture: architecture:
description: description:
- The archiecture for the container (e.g. "x86_64" or "i686"). - The archiecture for the container (e.g. "x86_64" or "i686").
See https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1 See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1)
required: false required: false
config: config:
description: description:
- > - 'The config for the container (e.g. {"limits.cpu": "2"}).
The config for the container (e.g. {"limits.cpu": "2"}). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1)'
See https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1
- If the container already exists and its "config" value in metadata - If the container already exists and its "config" value in metadata
obtained from obtained from
GET /1.0/containers/<name> GET /1.0/containers/<name>
https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10containersname U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10containersname)
are different, they this module tries to apply the configurations. are different, they this module tries to apply the configurations.
- The key starts with 'volatile.' are ignored for this comparison. - The key starts with 'volatile.' are ignored for this comparison.
- Not all config values are supported to apply the existing container. - Not all config values are supported to apply the existing container.
@ -53,26 +52,24 @@ options:
required: false required: false
devices: devices:
description: description:
- > - 'The devices for the container
The devices for the container
(e.g. { "rootfs": { "path": "/dev/kvm", "type": "unix-char" }). (e.g. { "rootfs": { "path": "/dev/kvm", "type": "unix-char" }).
See https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1 See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1)'
required: false required: false
ephemeral: ephemeral:
description: description:
- Whether or not the container is ephemeral (e.g. true or false). - Whether or not the container is ephemeral (e.g. true or false).
See https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1 See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1)
required: false required: false
source: source:
description: description:
- > - 'The source for the container
The source for the container
(e.g. { "type": "image", (e.g. { "type": "image",
"mode": "pull", "mode": "pull",
"server": "https://images.linuxcontainers.org", "server": "https://images.linuxcontainers.org",
"protocol": "lxd", "protocol": "lxd",
"alias": "ubuntu/xenial/amd64" }). "alias": "ubuntu/xenial/amd64" }).
See https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1 See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1)'
required: false required: false
state: state:
choices: choices:
@ -95,14 +92,14 @@ options:
default: 30 default: 30
wait_for_ipv4_addresses: wait_for_ipv4_addresses:
description: description:
- If this is true, the lxd_module waits until IPv4 addresses - If this is true, the M(lxd_container) waits until IPv4 addresses
are set to the all network interfaces in the container after are set to the all network interfaces in the container after
starting or restarting. starting or restarting.
required: false required: false
default: false default: false
force_stop: force_stop:
description: description:
- If this is true, the lxd_module forces to stop the container - If this is true, the M(lxd_container) forces to stop the container
when it stops or restarts the container. when it stops or restarts the container.
required: false required: false
default: false default: false
@ -115,21 +112,19 @@ options:
description: description:
- The client certificate key file path. - The client certificate key file path.
required: false required: false
default: > default: '"{}/.config/lxc/client.key" .format(os.environ["HOME"])'
'{}/.config/lxc/client.key'.format(os.environ['HOME'])
cert_file: cert_file:
description: description:
- The client certificate file path. - The client certificate file path.
required: false required: false
default: > default: '"{}/.config/lxc/client.crt" .format(os.environ["HOME"])'
'{}/.config/lxc/client.crt'.format(os.environ['HOME'])
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. running this module using the following command.
lxc config set core.trust_password <some random password> lxc config set core.trust_password <some random password>
See https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/ See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/)
- If trust_password is set, this module send a request for - If trust_password is set, this module send a request for
authentication before sending any requests. authentication before sending any requests.
required: false required: false
@ -142,14 +137,14 @@ notes:
2.1, the later requires python to be installed in the container which can 2.1, the later requires python to be installed in the container which can
be done with the command module. be done with the command module.
- You can copy a file from the host to the container - You can copy a file from the host to the container
with the Ansible `copy` and `template` module and the `lxd` connection plugin. with the Ansible M(copy) and M(templater) module and the `lxd` connection plugin.
See the example below. See the example below.
- You can copy a file in the creatd container to the localhost - You can copy a file in the creatd container to the localhost
with `command=lxc file pull container_name/dir/filename filename`. with `command=lxc file pull container_name/dir/filename filename`.
See the first example below. See the first example below.
""" '''
EXAMPLES = """ EXAMPLES = '''
# 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
@ -225,14 +220,9 @@ EXAMPLES = """
src: /etc/hosts src: /etc/hosts
dest: /tmp/mycontainer-hosts dest: /tmp/mycontainer-hosts
flat: true flat: true
""" '''
RETURN=""" RETURN='''
lxd_container:
description: container information
returned: success
type: object
contains:
addresses: addresses:
description: Mapping from the network device name to a list of IPv4 addresses in the container description: Mapping from the network device name to a list of IPv4 addresses in the container
returned: when state is started or restarted returned: when state is started or restarted
@ -241,16 +231,19 @@ lxd_container:
old_state: old_state:
description: The old state of the container description: The old state of the container
returned: when state is started or restarted returned: when state is started or restarted
type: string
sample: "stopped" sample: "stopped"
logs: logs:
descriptions: The logs of requests and responses. description: The logs of requests and responses.
returned: when ansible-playbook is invoked with -vvvv. returned: when ansible-playbook is invoked with -vvvv.
type: list
sample: "(too long to be placed here)"
actions: actions:
description: List of actions performed for the container. description: List of actions performed for the container.
returned: success returned: success
type: list type: list
sample: ["create", "start"] sample: '["create", "start"]'
""" '''
import os import os
from ansible.modules.extras.cloud.lxd import LXDClient, LXDClientException from ansible.modules.extras.cloud.lxd import LXDClient, LXDClientException

@ -19,7 +19,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
DOCUMENTATION = """ DOCUMENTATION = '''
--- ---
module: lxd_profile module: lxd_profile
short_description: Manage LXD profiles short_description: Manage LXD profiles
@ -34,29 +34,27 @@ options:
required: true required: true
config: config:
description: description:
- > - 'The config for the container (e.g. {"limits.memory": "4GB"}).
The config for the container (e.g. {"limits.memory": "4GB"}). See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3)'
See https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3
- If the profile already exists and its "config" value in metadata - If the profile already exists and its "config" value in metadata
obtained from obtained from
GET /1.0/profiles/<name> GET /1.0/profiles/<name>
https://github.com/lxc/lxd/blob/master/doc/rest-api.md#get-19 U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#get-19)
are different, they this module tries to apply the configurations. are different, they this module tries to apply the configurations.
- Not all config values are supported to apply the existing profile. - Not all config values are supported to apply the existing profile.
Maybe you need to delete and recreate a profile. Maybe you need to delete and recreate a profile.
required: false required: false
devices: devices:
description: description:
- > - 'The devices for the profile
The devices for the profile
(e.g. {"rootfs": {"path": "/dev/kvm", "type": "unix-char"}). (e.g. {"rootfs": {"path": "/dev/kvm", "type": "unix-char"}).
See https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3 See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-3)'
required: false required: false
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 https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-11 See U(https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-11)
required: false required: false
state: state:
choices: choices:
@ -75,21 +73,19 @@ options:
description: description:
- The client certificate key file path. - The client certificate key file path.
required: false required: false
default: > default: '"{}/.config/lxc/client.key" .format(os.environ["HOME"])'
'{}/.config/lxc/client.key'.format(os.environ['HOME'])
cert_file: cert_file:
description: description:
- The client certificate file path. - The client certificate file path.
required: false required: false
default: > default: '"{}/.config/lxc/client.crt" .format(os.environ["HOME"])'
'{}/.config/lxc/client.crt'.format(os.environ['HOME'])
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. running this module using the following command.
lxc config set core.trust_password <some random password> lxc config set core.trust_password <some random password>
See https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/ See U(https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/)
- If trust_password is set, this module send a request for - If trust_password is set, this module send a request for
authentication before sending any requests. authentication before sending any requests.
required: false required: false
@ -97,9 +93,9 @@ 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 = '''
# An example for creating a profile # An example for creating a profile
- hosts: localhost - hosts: localhost
connection: local connection: local
@ -155,26 +151,25 @@ EXAMPLES = """
name: macvlan name: macvlan
new_name: macvlan2 new_name: macvlan2
state: present state: present
""" '''
RETURN=""" RETURN='''
lxd_profile:
description: profile information
returned: success
type: object
contains:
old_state: old_state:
description: The old state of the profile description: The old state of the profile
returned: success
type: string
sample: "absent" sample: "absent"
logs: logs:
descriptions: The logs of requests and responses. description: The logs of requests and responses.
returned: when ansible-playbook is invoked with -vvvv. returned: when ansible-playbook is invoked with -vvvv.
type: list
sample: "(too long to be placed here)"
actions: actions:
description: List of actions performed for the profile. description: List of actions performed for the profile.
returned: success returned: success
type: list type: list
sample: ["create"] sample: '["create"]'
""" '''
import os import os
from ansible.modules.extras.cloud.lxd import LXDClient, LXDClientException from ansible.modules.extras.cloud.lxd import LXDClient, LXDClientException

Loading…
Cancel
Save