ansible.builtin.rds (v2.7.18) — module

create, delete, or modify an Amazon rds instance

| "added in version" 1.3 of ansible.builtin"

Authors: Bruce Pennypacker (@bpennypacker), Will Thames (@willthames)

stableinterface | supported by community

Install Ansible via pip

Install with pip install ansible==2.7.18

Description

Creates, deletes, or modifies rds instances. When creating an instance it can be either a new instance or a read-only replica of an existing instance. This module has a dependency on python-boto >= 2.5. The 'promote' command requires boto >= 2.18.0. Certain features such as tags rely on boto.rds2 (boto >= 2.26.0)


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Basic mysql provisioning example
- rds:
    command: create
    instance_name: new-database
    db_engine: MySQL
    size: 10
    instance_type: db.m1.small
    username: mysql_admin
    password: 1nsecure
    tags:
      Environment: testing
      Application: cms
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Create a read-only replica and wait for it to become available
- rds:
    command: replicate
    instance_name: new-database-replica
    source_instance: new_database
    wait: yes
    wait_timeout: 600
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Delete an instance, but create a snapshot before doing so
- rds:
    command: delete
    instance_name: new-database
    snapshot: new_database_snapshot
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Get facts about an instance
- rds:
    command: facts
    instance_name: new-database
  register: new_database_facts
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Rename an instance and wait for the change to take effect
- rds:
    command: modify
    instance_name: new-database
    new_instance_name: renamed-database
    wait: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Reboot an instance and wait for it to become available again
- rds:
    command: reboot
    instance_name: database
    wait: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Restore a Postgres db instance from a snapshot, wait for it to become available again, and
#  then modify it to add your security group. Also, display the new endpoint.
#  Note that the "publicly_accessible" option is allowed here just as it is in the AWS CLI
- local_action:
     module: rds
     command: restore
     snapshot: mypostgres-snapshot
     instance_name: MyNewInstanceName
     region: us-west-2
     zone: us-west-2b
     subnet: default-vpc-xx441xxx
     publicly_accessible: yes
     wait: yes
     wait_timeout: 600
     tags:
         Name: pg1_test_name_tag
  register: rds
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- local_action:
     module: rds
     command: modify
     instance_name: MyNewInstanceName
     region: us-west-2
     vpc_security_groups: sg-xxx945xx
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    msg: "The new db endpoint is {{ rds.instance.endpoint }}"

Inputs

    
iops:
    description:
    - Specifies the number of IOPS for the instance.  Used only when command=create or
      command=modify. Must be an integer greater than 1000.

port:
    default: 3306 for mysql, 1521 for Oracle, 1433 for SQL Server, 5432 for PostgreSQL.
    description:
    - Port number that the DB instance uses for connections. Used only when command=create
      or command=replicate.
    - Prior to 2.0 it always defaults to null and the API would use 3306, it had to be
      set to other DB default values when not using MySql. Starting at 2.0 it automatically
      defaults to what is expected for each C(db_engine).

size:
    description:
    - Size in gigabytes of the initial storage for the DB instance. Used only when command=create
      or command=modify.

tags:
    description:
    - tags dict to apply to a resource. Used with command=create, command=replicate, command=restore.
      Requires boto >= 2.26.0
    version_added: '1.9'
    version_added_collection: ansible.builtin

wait:
    default: 'no'
    description:
    - When command=create, replicate, modify or restore then wait for the database to
      enter the 'available' state.  When command=delete wait for the database to be terminated.
    type: bool

zone:
    aliases:
    - aws_zone
    - ec2_zone
    description:
    - availability zone in which to launch the instance. Used only when command=create,
      command=replicate or command=restore.

region:
    aliases:
    - aws_region
    - ec2_region
    description:
    - The AWS region to use. If not specified then the value of the EC2_REGION environment
      variable, if any, is used.
    required: true
    type: str

subnet:
    description:
    - VPC subnet group.  If specified then a VPC instance is created. Used only when command=create.

command:
    choices:
    - create
    - replicate
    - delete
    - facts
    - modify
    - promote
    - snapshot
    - reboot
    - restore
    description:
    - Specifies the action to take. The 'reboot' option is available starting at version
      2.0
    required: true

db_name:
    description:
    - Name of a database to create within the instance.  If not specified then no database
      is created. Used only when command=create.

ec2_url:
    description:
    - Url to use to connect to EC2 or your Eucalyptus cloud (by default the module will
      use EC2 endpoints). Ignored for modules where region is required. Must be specified
      for all other modules if region is not used. If not set then the value of the EC2_URL
      environment variable, if any, is used.
    type: str

profile:
    description:
    - Uses a boto profile. Only works with boto >= 2.24.0.
    type: str

upgrade:
    default: 'no'
    description:
    - Indicates that minor version upgrades should be applied automatically. Used only
      when command=create or command=replicate.
    type: bool

password:
    description:
    - Password for the master database username. Used only when command=create or command=modify.

snapshot:
    description:
    - Name of snapshot to take. When command=delete, if no snapshot name is provided then
      no snapshot is taken. If used with command=delete with no instance_name, the snapshot
      is deleted. Used with command=facts, command=delete or command=snapshot.

username:
    description:
    - Master database username. Used only when command=create.

db_engine:
    choices:
    - mariadb
    - MySQL
    - oracle-se1
    - oracle-se2
    - oracle-se
    - oracle-ee
    - sqlserver-ee
    - sqlserver-se
    - sqlserver-ex
    - sqlserver-web
    - postgres
    - aurora
    description:
    - The type of database.  Used only when command=create.
    - mariadb was added in version 2.2

aws_config:
    description:
    - A dictionary to modify the botocore configuration.
    - Parameters can be found at U(https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config).
    - Only the 'user_agent' key is used for boto modules. See U(http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto)
      for more boto configuration.
    type: dict

multi_zone:
    description:
    - Specifies if this is a Multi-availability-zone deployment. Can not be used in conjunction
      with zone parameter. Used only when command=create or command=modify.
    type: bool

maint_window:
    description:
    - 'Maintenance window in format of ddd:hh24:mi-ddd:hh24:mi.  (Example: Mon:22:00-Mon:23:15)
      If not specified then a random maintenance window is assigned. Used only when command=create
      or command=modify.

      '

option_group:
    description:
    - The name of the option group to use.  If not specified then the default option group
      is used. Used only when command=create.

wait_timeout:
    default: 300
    description:
    - how long before wait gives up, in seconds

backup_window:
    description:
    - Backup window in format of hh24:mi-hh24:mi.  If not specified then a random backup
      window is assigned. Used only when command=create or command=modify.

instance_name:
    description:
    - Database instance identifier. Required except when using command=facts or command=delete
      on just a snapshot

instance_type:
    description:
    - The instance type of the database.  Must be specified when command=create. Optional
      when command=replicate, command=modify or command=restore. If not specified then
      the replica inherits the same instance type as the source instance.

license_model:
    choices:
    - license-included
    - bring-your-own-license
    - general-public-license
    - postgresql-license
    description:
    - The license model for this DB instance. Used only when command=create or command=restore.

aws_access_key:
    aliases:
    - ec2_access_key
    - access_key
    description:
    - AWS access key. If not set then the value of the AWS_ACCESS_KEY environment variable
      is used.
    type: str

aws_secret_key:
    aliases:
    - ec2_secret_key
    - secret_key
    description:
    - AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable
      is used.
    type: str

engine_version:
    description:
    - Version number of the database engine to use. Used only when command=create. If
      not specified then the current Amazon RDS default engine version is used

force_failover:
    default: 'no'
    description:
    - Used only when command=reboot.  If enabled, the reboot is done using a MultiAZ failover.
    type: bool
    version_added: '2.0'
    version_added_collection: ansible.builtin

security_token:
    aliases:
    - access_token
    description:
    - AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN
      environment variable is used.
    type: str

validate_certs:
    default: true
    description:
    - When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.
    type: bool

parameter_group:
    description:
    - Name of the DB parameter group to associate with this instance.  If omitted then
      the RDS default DBParameterGroup will be used. Used only when command=create or
      command=modify.

security_groups:
    description:
    - Comma separated list of one or more security groups.  Used only when command=create
      or command=modify.

source_instance:
    description:
    - Name of the database to replicate. Used only when command=replicate.

backup_retention:
    description:
    - 'Number of days backups are retained.  Set to 0 to disable backups.  Default is
      1 day.  Valid range: 0-35. Used only when command=create or command=modify.

      '

apply_immediately:
    default: 'no'
    description:
    - Used only when command=modify.  If enabled, the modifications will be applied as
      soon as possible rather than waiting for the next preferred maintenance window.
    type: bool

new_instance_name:
    description:
    - Name to rename an instance to. Used only when command=modify.
    version_added: '1.5'
    version_added_collection: ansible.builtin

character_set_name:
    description:
    - Associate the DB instance with a specified character set. Used with command=create.
    version_added: '1.9'
    version_added_collection: ansible.builtin

publicly_accessible:
    description:
    - explicitly set whether the resource should be publicly accessible or not. Used with
      command=create, command=replicate. Requires boto >= 2.26.0
    version_added: '1.9'
    version_added_collection: ansible.builtin

vpc_security_groups:
    description:
    - Comma separated list of one or more vpc security group ids. Also requires `subnet`
      to be specified. Used only when command=create or command=modify.

debug_botocore_endpoint_logs:
    default: 'no'
    description:
    - Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action"
      API calls made during a task, outputing the set to the resource_actions key in the
      task results. Use the aws_resource_action callback to output to total list made
      during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also
      be used.
    type: bool

Outputs

allocated_storage:
  description: the allocated storage size in gigabytes (GB)
  returned: when RDS instance exists
  sample: '100'
  type: string
auto_minor_version_upgrade:
  description: indicates that minor engine upgrades will be applied automatically
    to the DB instance during the maintenance window
  returned: when RDS instance exists
  sample: 'true'
  type: boolean
backup_window:
  description: the daily time range during which automated backups are created if
    automated backups are enabled
  returned: when RDS instance exists and automated backups are enabled
  sample: 03:00-03:30
  type: string
character_set_name:
  description: the name of the character set that this instance is associated with
  returned: when RDS instance exists
  sample: AL32UTF8
  type: string
db_name:
  description: the name of the database to create when the DB instance is created
  returned: when RDS instance exists
  sample: ASERTG
  type: string
db_subnet_groups:
  contains:
    description:
      description: the subnet group associated with the DB instance
      returned: when RDS instance exists
      sample: Subnets for the UAT RDS SQL DB Instance
      type: string
    name:
      description: the name of the DB subnet group
      returned: when RDS instance exists
      sample: samplesubnetgrouprds-j6paiqkxqp4z
      type: string
    status:
      description: the status of the DB subnet group
      returned: when RDS instance exists
      sample: complete
      type: string
    subnets:
      contains:
        availability_zone:
          contains:
            name:
              description: avaialbility zone
              returned: when RDS instance exists
              sample: eu-west-1b
              type: string
            provisioned_iops_capable:
              description: whether provisioned iops are available in AZ subnet
              returned: when RDS instance exists
              sample: 'false'
              type: boolean
          description: subnet availability zone information
          returned: when RDS instance exists
          type: complex
        identifier:
          description: the identifier of the subnet
          returned: when RDS instance exists
          sample: subnet-3fdba63e
          type: string
        status:
          description: the status of the subnet
          returned: when RDS instance exists
          sample: active
          type: string
      description: the description of the DB subnet group
      returned: when RDS instance exists
      type: complex
  description: information on the subnet group associated with this RDS instance
  returned: when RDS instance exists
  type: complex
engine:
  description: the name of the database engine
  returned: when RDS instance exists
  sample: oracle-se
  type: string
engine_version:
  description: the version of the database engine
  returned: when RDS instance exists
  sample: 11.2.0.4.v6
  type: string
latest_restorable_time:
  description: the latest time to which a database can be restored with point-in-time
    restore
  returned: when RDS instance exists
  sample: '1489707802.0'
  type: string
license_model:
  description: the license model information
  returned: when RDS instance exists
  sample: bring-your-own-license
  type: string
option_groups:
  contains:
    option_group_name:
      description: the option group name for this RDS instance
      returned: when RDS instance exists
      sample: default:oracle-se-11-2
      type: string
    status:
      description: the status of the RDS instance's option group membership
      returned: when RDS instance exists
      sample: in-sync
      type: string
  description: the list of option group memberships for this RDS instance
  returned: when RDS instance exists
  type: complex
parameter_groups:
  contains:
    parameter_apply_status:
      description: the status of parameter updates
      returned: when RDS instance exists
      sample: in-sync
      type: string
    parameter_group_name:
      description: the name of the DP parameter group
      returned: when RDS instance exists
      sample: testawsrpprodb01spfile-1ujg7nrs7sgyz
      type: string
  description: the list of DB parameter groups applied to this RDS instance
  returned: when RDS instance exists and parameter groups are defined
  type: complex
pending_modified_values:
  contains:
    allocated_storage:
      description: the new allocated storage size for this RDS instance that will
        be applied or is in progress
      returned: when RDS instance exists
      sample: 'null'
      type: string
    backup_retention_period:
      description: the pending number of days for which automated backups are retained
      returned: when RDS instance exists
      sample: 'null'
      type: string
    db_instance_class:
      description: the new DB instance class for this RDS instance that will be applied
        or is in progress
      returned: when RDS instance exists
      sample: 'null'
      type: string
    db_instance_identifier:
      description: the new DB instance identifier this RDS instance that will be applied
        or is in progress
      returned: when RDS instance exists
      sample: 'null'
      type: string
    engine_version:
      description: indicates the database engine version
      returned: when RDS instance exists
      sample: 'null'
      type: string
    iops:
      description: the new provisioned IOPS value for this RDS instance that will
        be applied or is being applied
      returned: when RDS instance exists
      sample: 'null'
      type: string
    master_user_password:
      description: the pending or in-progress change of the master credentials for
        this RDS instance
      returned: when RDS instance exists
      sample: 'null'
      type: string
    multi_az:
      description: indicates that the single-AZ RDS instance is to change to a multi-AZ
        deployment
      returned: when RDS instance exists
      sample: 'null'
      type: string
    port:
      description: specifies the pending port for this RDS instance
      returned: when RDS instance exists
      sample: 'null'
      type: string
  description: a dictionary of changes to the RDS instance that are pending
  returned: when RDS instance exists
  type: complex
publicly_accessible:
  description: the accessibility options for the DB instance
  returned: when RDS instance exists
  sample: 'true'
  type: boolean
read_replica_source_dbinstance_identifier:
  description: the identifier of the source DB instance if this RDS instance is a
    read replica
  returned: when read replica RDS instance exists
  sample: 'null'
  type: string
secondary_availability_zone:
  description: the name of the secondary AZ for a DB instance with multi-AZ support
  returned: when RDS instance exists and is multy-AZ
  sample: eu-west-1b
  type: string