google.cloud.gcp_parameter_manager module – Access and Update Google Cloud Parameter Manager objects

Note

This module is part of the google.cloud collection (version 1.7.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install google.cloud. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: google.cloud.gcp_parameter_manager.

Synopsis

  • Access and Update Google Cloud Parameter Manager objects

  • Create new parameters.

  • Create new parameters with format.

  • Create new parameters with labels.

  • Create new parameters with format and labels.

  • Add/Remove parameter version.

  • Remove parameter.

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 3.7

  • requests >= 2.32.3

  • google-auth >= 2.39.0

Parameters

Parameter

Comments

access_token

string

An OAuth2 access token if credential type is accesstoken.

auth_kind

string / required

The type of credential used.

Choices:

  • "application"

  • "machineaccount"

  • "serviceaccount"

  • "accesstoken"

env_type

string

Specifies which Ansible environment you’re running this module within.

This should not be set unless you know what you’re doing.

This only alters the User Agent string for any API requests.

format

string

Format of the parameter to be used.

Choices:

  • "UNFORMATTED" ← (default)

  • "JSON"

  • "YAML"

labels

dictionary

A set of key-value pairs to assign as labels to a parameter

only used in creation

Note that the “value” piece of a label must contain only readable chars

Default: {}

location

string

Location of the parameter to be used

Default: "global"

name

aliases: key, parameter, parameter_id

string / required

Name of the parameter to be used

project

string

The Google Cloud Platform project to use. Defaults to OS env variable GCP_PROJECT if not present

return_value

boolean

if true, the value of the parameter will be returned unencrypted to Ansible

if false, no value will be returned or decrypted

Choices:

  • false

  • true ← (default)

scopes

list / elements=string

Array of scopes to be used

service_account_contents

jsonarg

The contents of a Service Account JSON file, either in a dictionary or as a JSON string that represents it.

service_account_email

string

An optional service account email address if machineaccount is selected and the user does not wish to use the default email.

service_account_file

path

The path of a Service Account JSON file if serviceaccount is selected as type.

state

string

whether the parameter should exist

Choices:

  • "absent"

  • "present" ← (default)

value

string

The parameter value that the parameter should have

this will be set upon create

If the parameter value is not this, a new version will be added with this value

version

aliases: version_id, parameter_version_id

string

Name of the parameter to be used

Examples

- name: Create a new parameter
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json

- name: Create a new parameter with version
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    value: super_parameter
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json

- name: Create a new structured parameter
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    format: JSON
    value: '{"key":"value"}'
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json

- name: Create a parameter with labels
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    value: super_parameter
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json
    labels:
      key_name: "ansible_rox"

- name: Create a structured parameter with labels
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    format: JSON
    value: '{"key":"value"}'
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json
    labels:
      key_name: "ansible_rox"

- name: Ensure the parameter exists, fail otherwise and return the value
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    state: present

- name: Ensure parameter exists but don't return the value
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    state: present
    return_value: false

- name: Add a new version of a parameter
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    value: updated super parameter
    state: present

- name: Delete version 1 of a parameter (but not the parameter itself)
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    state: absent

- name: Delete parameter
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    state: absent

- name: Create a new regional parameter
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json

- name: Create a new regional parameter with version
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    value: super_parameter
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json

- name: Create a new structured regional parameter
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    format: JSON
    value: '{"key":"value"}'
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json

- name: Create a regional parameter with labels
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    value: super_parameter
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json
    labels:
      key_name: "ansible_rox"

- name: Create a structured regional parameter with labels
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    format: JSON
    value: '{"key":"value"}'
    state: present
    auth_kind: serviceaccount
    service_account_file: service_account_creds.json
    labels:
      key_name: "ansible_rox"

- name: Ensure the regional parameter exists, fail otherwise and return the value
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    state: present

- name: Ensure regional parameter exists but don't return the value
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    state: present
    return_value: false

- name: Add a new version of a regional parameter
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    value: updated super parameter
    state: present

- name: Delete version 1 of a regional parameter (but not the regional parameter itself)
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    version: version_key
    state: absent

- name: Delete parameter
  google.cloud.gcp_parameter_manager:
    name: parameter_key
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

resources

complex

List of resources

Returned: always

location

string

The location of the regional parameter

Returned: success

msg

string

A message indicating what was done (or not done)

Returned: success, failure

name

string

The name of the parameter

Returned: success

payload

dictionary

The base 64 parameter payload

Returned: success

status_code

string

the HTTP status code of the response to Google Cloud

Returned: success

url

string

the Google Cloud URL used to make the request

Returned: success

value

string

The decrypted parameter data value, please use care with this

Returned: success

version

string

the version of the parameter returned

Returned: success

Authors

  • Google Inc. (@googlecloudplatform)