mercredi 2 octobre 2019

Testing Ansible role that creates AWS resources with molecule

I have an ansible role that creates and provisions an RDS instance, similar to the example below (which is taken from the ansible docs)

- name: Create an encrypted DB instance
  rds_instance:
    id: test-encrypted-db
    state: present
    engine: mariadb
    storage_encrypted: True
    db_instance_class: db.t2.medium
    username: "username"
    password: "strong_password"
    allocated_storage: 30

Is there any way to test that the instance has been created and has the correct attributes applied with molecule & testinfra? Also, how would one terminate this instance after the tests have finished?

At the moment, I've only found ways to test provisioning an instance that was created prior to the role running (eg. in create.yml and destroyed in molecule's destroy.yml). Any other approach (eg. mocking the AWS SDK with moto) is welcome as well.

Aucun commentaire:

Enregistrer un commentaire