PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/test/integration/roles/setup_ec2/tasks/common.yml

https://github.com/ajanthanm/ansible
YAML | 119 lines | 92 code | 18 blank | 9 comment | 0 complexity | 8829f2ed6d814f3d59ec2eeb17729fba MD5 | raw file
  1---
  2
  3# ============================================================
  4- name: test with no parameters
  5  action: "{{module_name}}"
  6  register: result
  7  ignore_errors: true
  8
  9- name: assert failure when called with no parameters
 10  assert:
 11    that:
 12       - 'result.failed'
 13       - 'result.msg == "missing required arguments: name"'
 14
 15# ============================================================
 16- name: test with only name
 17  action: "{{module_name}} name={{ec2_key_name}}"
 18  register: result
 19  ignore_errors: true
 20
 21- name: assert failure when called with only 'name'
 22  assert:
 23    that:
 24       - 'result.failed'
 25       - 'result.msg == "Either region or ec2_url must be specified"'
 26
 27# ============================================================
 28- name: test invalid region parameter
 29  action: "{{module_name}} name='{{ec2_key_name}}' region='asdf querty 1234'"
 30  register: result
 31  ignore_errors: true
 32
 33- name: assert invalid region parameter
 34  assert:
 35    that:
 36       - 'result.failed'
 37       - 'result.msg.startswith("value of region must be one of:")'
 38
 39# ============================================================
 40- name: test valid region parameter
 41  action: "{{module_name}} name='{{ec2_key_name}}' region='{{ec2_region}}'"
 42  register: result
 43  ignore_errors: true
 44
 45- name: assert valid region parameter
 46  assert:
 47    that:
 48       - 'result.failed'
 49       - 'result.msg.startswith("No handler was ready to authenticate.")'
 50
 51# ============================================================
 52- name: test environment variable EC2_REGION
 53  action: "{{module_name}} name='{{ec2_key_name}}'"
 54  environment:
 55    EC2_REGION: '{{ec2_region}}'
 56  register: result
 57  ignore_errors: true
 58
 59- name: assert environment variable EC2_REGION
 60  assert:
 61    that:
 62       - 'result.failed'
 63       - 'result.msg.startswith("No handler was ready to authenticate.")'
 64
 65# ============================================================
 66- name: test invalid ec2_url parameter
 67  action: "{{module_name}} name='{{ec2_key_name}}'"
 68  environment:
 69    EC2_URL: bogus.example.com
 70  register: result
 71  ignore_errors: true
 72
 73- name: assert invalid ec2_url parameter
 74  assert:
 75    that:
 76       - 'result.failed'
 77       - 'result.msg.startswith("No handler was ready to authenticate.")'
 78
 79# ============================================================
 80- name: test valid ec2_url parameter
 81  action: "{{module_name}} name='{{ec2_key_name}}'"
 82  environment:
 83    EC2_URL: '{{ec2_url}}'
 84  register: result
 85  ignore_errors: true
 86
 87- name: assert valid ec2_url parameter
 88  assert:
 89    that:
 90       - 'result.failed'
 91       - 'result.msg.startswith("No handler was ready to authenticate.")'
 92
 93# ============================================================
 94- name: test credentials from environment
 95  action: "{{module_name}} name='{{ec2_key_name}}'"
 96  environment:
 97    EC2_REGION: '{{ec2_region}}'
 98    EC2_ACCESS_KEY: bogus_access_key
 99    EC2_SECRET_KEY: bogus_secret_key
100  register: result
101  ignore_errors: true
102
103- name: assert ec2_key with valid ec2_url
104  assert:
105    that:
106       - 'result.failed'
107       - '"EC2ResponseError: 401 Unauthorized" in result.msg'
108
109# ============================================================
110- name: test credential parameters
111  action: "{{module_name}} name='{{ec2_key_name}}' ec2_region='{{ec2_region}}' ec2_access_key=bogus_access_key ec2_secret_key=bogus_secret_key"
112  register: result
113  ignore_errors: true
114
115- name: assert credential parameters
116  assert:
117    that:
118       - 'result.failed'
119       - '"EC2ResponseError: 401 Unauthorized" in result.msg'