diff --git a/changelogs/fragments/1270-linode-v4-stackscript-support.yaml b/changelogs/fragments/1270-linode-v4-stackscript-support.yaml new file mode 100644 index 0000000000..7b91e3f640 --- /dev/null +++ b/changelogs/fragments/1270-linode-v4-stackscript-support.yaml @@ -0,0 +1,2 @@ +minor_changes: + - linode_v4 - added support for Linode StackScript usage when creating instances (https://github.com/ansible-collections/community.general/issues/723). diff --git a/plugins/modules/cloud/linode/linode_v4.py b/plugins/modules/cloud/linode/linode_v4.py index 7990cb34ae..c70ebda5b6 100644 --- a/plugins/modules/cloud/linode/linode_v4.py +++ b/plugins/modules/cloud/linode/linode_v4.py @@ -27,21 +27,21 @@ options: description: - The region of the instance. This is a required parameter only when creating Linode instances. See - U(https://developers.linode.com/api/v4#tag/Regions). + U(https://www.linode.com/docs/api/regions/). required: false type: str image: description: - The image of the instance. This is a required parameter only when creating Linode instances. See - U(https://developers.linode.com/api/v4#tag/Images). + U(https://www.linode.com/docs/api/images/). type: str required: false type: description: - The type of the instance. This is a required parameter only when creating Linode instances. See - U(https://developers.linode.com/api/v4#tag/Linode-Types). + U(https://www.linode.com/docs/api/linode-types/). type: str required: false label: @@ -60,7 +60,7 @@ options: tags: description: - The tags that the instance should be marked under. See - U(https://developers.linode.com/api/v4#tag/Tags). + U(https://www.linode.com/docs/api/tags/). required: false type: list root_pass: @@ -87,8 +87,22 @@ options: description: - The Linode API v4 access token. It may also be specified by exposing the C(LINODE_ACCESS_TOKEN) environment variable. See - U(https://developers.linode.com/api/v4#section/Access-and-Authentication). + U(https://www.linode.com/docs/api#access-and-authentication). required: true + stackscript_id: + description: + - The numeric ID of the StackScript to use when creating the instance. + See U(https://www.linode.com/docs/api/stackscripts/). + type: int + version_added: 1.3.0 + stackscript_data: + description: + - An object containing arguments to any User Defined Fields present in + the StackScript used when creating the instance. + Only valid when a stackscript_id is provided. + See U(https://www.linode.com/docs/api/stackscripts/). + type: dict + version_added: 1.3.0 ''' EXAMPLES = """ @@ -101,6 +115,9 @@ EXAMPLES = """ root_pass: passw0rd authorized_keys: - "ssh-rsa ..." + stackscript_id: 1337 + stackscript_data: + variable: value state: present - name: Delete that new Linode. @@ -229,6 +246,8 @@ def initialise_module(): root_pass=dict(type='str', required=False, no_log=True), tags=dict(type='list', required=False), type=dict(type='str', required=False), + stackscript_id=dict(type='int', required=False), + stackscript_data=dict(type='dict', required=False), ), supports_check_mode=False, required_one_of=( @@ -272,6 +291,8 @@ def main(): root_pass=module.params['root_pass'], tags=module.params['tags'], ltype=module.params['type'], + stackscript=module.params['stackscript_id'], + stackscript_data=module.params['stackscript_data'], ) module.exit_json(changed=True, instance=instance_json)