mirror of https://github.com/ansible/ansible.git
Mass update of test/ directory from devel
parent
43cd33888b
commit
6b1648f708
@ -0,0 +1,2 @@
|
||||
testhost ansible_connection=local
|
||||
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- test_cs_common
|
@ -0,0 +1,211 @@
|
||||
---
|
||||
- name: setup cluster is absent
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
state: absent
|
||||
register: cluster
|
||||
- name: verify setup cluster is absent
|
||||
assert:
|
||||
that:
|
||||
- cluster|success
|
||||
|
||||
- name: setup zone is present
|
||||
cs_zone:
|
||||
name: "{{ cs_resource_prefix }}-zone"
|
||||
dns1: 8.8.8.8
|
||||
dns2: 8.8.4.4
|
||||
network_type: basic
|
||||
register: zone
|
||||
- name: verify setup zone is present
|
||||
assert:
|
||||
that:
|
||||
- zone|success
|
||||
|
||||
- name: setup pod is preset
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
start_ip: 10.100.10.101
|
||||
gateway: 10.100.10.1
|
||||
netmask: 255.255.255.0
|
||||
register: pod
|
||||
- name: verify setup pod is preset
|
||||
assert:
|
||||
that:
|
||||
- pod|success
|
||||
|
||||
- name: test fail if missing name
|
||||
cs_cluster:
|
||||
register: cluster
|
||||
ignore_errors: true
|
||||
- name: verify results of fail if missing name
|
||||
assert:
|
||||
that:
|
||||
- cluster|failed
|
||||
- "cluster.msg == 'missing required arguments: name'"
|
||||
|
||||
- name: test create cluster
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
hypervisor: simulator
|
||||
cluster_type: CloudManaged
|
||||
register: cluster_origin
|
||||
tags: disable
|
||||
- name: verify test create cluster
|
||||
assert:
|
||||
that:
|
||||
- cluster_origin|changed
|
||||
- cluster_origin.name == "{{ cs_resource_prefix }}-cluster"
|
||||
- cluster_origin.zone == "{{ cs_resource_prefix }}-zone"
|
||||
- cluster_origin.allocation_state == "Enabled"
|
||||
- cluster_origin.hypervisor == "Simulator"
|
||||
- cluster_origin.cluster_type == "CloudManaged"
|
||||
|
||||
- name: test create cluster idempotence
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-Cluster"
|
||||
zone: "{{ cs_resource_prefix }}-Zone"
|
||||
hypervisor: Simulator
|
||||
cluster_type: CloudManaged
|
||||
register: cluster
|
||||
- name: verify test create cluster idempotence
|
||||
assert:
|
||||
that:
|
||||
- cluster.id == cluster_origin.id
|
||||
- not cluster|changed
|
||||
- cluster.name == "{{ cs_resource_prefix }}-cluster"
|
||||
- cluster.zone == "{{ cs_resource_prefix }}-zone"
|
||||
- cluster.allocation_state == "Enabled"
|
||||
- cluster_origin.hypervisor == "Simulator"
|
||||
- cluster.cluster_type == "CloudManaged"
|
||||
|
||||
- name: test update cluster
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
hypervisor: simulator
|
||||
cluster_type: ExternalManaged
|
||||
register: cluster
|
||||
- name: verify test update cluster
|
||||
assert:
|
||||
that:
|
||||
- cluster|changed
|
||||
- cluster.name == "{{ cs_resource_prefix }}-cluster"
|
||||
- cluster.zone == "{{ cs_resource_prefix }}-zone"
|
||||
- cluster.allocation_state == "Enabled"
|
||||
- cluster.hypervisor == "Simulator"
|
||||
- cluster.cluster_type == "ExternalManaged"
|
||||
- cluster.id == cluster_origin.id
|
||||
|
||||
- name: test update cluster idempotence
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
hypervisor: simulator
|
||||
cluster_type: ExternalManaged
|
||||
register: cluster
|
||||
- name: verify test update cluster idempotence
|
||||
assert:
|
||||
that:
|
||||
- not cluster|changed
|
||||
- cluster.name == "{{ cs_resource_prefix }}-cluster"
|
||||
- cluster.zone == "{{ cs_resource_prefix }}-zone"
|
||||
- cluster.allocation_state == "Enabled"
|
||||
- cluster.hypervisor == "Simulator"
|
||||
- cluster.cluster_type == "ExternalManaged"
|
||||
- cluster.id == cluster_origin.id
|
||||
|
||||
- name: test disable cluster
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
state: disabled
|
||||
register: cluster
|
||||
tags: disable
|
||||
- name: verify test disable cluster
|
||||
assert:
|
||||
that:
|
||||
- cluster|changed
|
||||
- cluster.name == "{{ cs_resource_prefix }}-cluster"
|
||||
- cluster.zone == "{{ cs_resource_prefix }}-zone"
|
||||
- cluster.allocation_state == "Disabled"
|
||||
- cluster.hypervisor == "Simulator"
|
||||
- cluster.cluster_type == "ExternalManaged"
|
||||
- cluster.id == cluster_origin.id
|
||||
tags: disable
|
||||
|
||||
- name: test disable cluster idempotence
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
state: disabled
|
||||
register: cluster
|
||||
tags: disable
|
||||
- name: verify test disable cluster idempotence
|
||||
assert:
|
||||
that:
|
||||
- not cluster|changed
|
||||
- cluster.name == "{{ cs_resource_prefix }}-cluster"
|
||||
- cluster.zone == "{{ cs_resource_prefix }}-zone"
|
||||
- cluster.allocation_state == "Disabled"
|
||||
- cluster.hypervisor == "Simulator"
|
||||
- cluster.cluster_type == "ExternalManaged"
|
||||
tags: disable
|
||||
|
||||
- name: test enable cluster
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
state: enabled
|
||||
register: cluster
|
||||
- name: verify test enable cluster
|
||||
assert:
|
||||
that:
|
||||
- cluster|changed
|
||||
- cluster.name == "{{ cs_resource_prefix }}-cluster"
|
||||
- cluster.zone == "{{ cs_resource_prefix }}-zone"
|
||||
- cluster.allocation_state == "Enabled"
|
||||
- cluster.hypervisor == "Simulator"
|
||||
- cluster.cluster_type == "ExternalManaged"
|
||||
- cluster.id == cluster_origin.id
|
||||
|
||||
- name: test enable cluster idempotence
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
state: enabled
|
||||
register: cluster
|
||||
- name: verify test enable cluster idempotence
|
||||
assert:
|
||||
that:
|
||||
- not cluster|changed
|
||||
- cluster.name == "{{ cs_resource_prefix }}-cluster"
|
||||
- cluster.zone == "{{ cs_resource_prefix }}-zone"
|
||||
- cluster.allocation_state == "Enabled"
|
||||
- cluster.hypervisor == "Simulator"
|
||||
- cluster.cluster_type == "ExternalManaged"
|
||||
- cluster.id == cluster_origin.id
|
||||
|
||||
- name: test remove cluster
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
state: absent
|
||||
register: cluster
|
||||
- name: verify test remove cluster
|
||||
assert:
|
||||
that:
|
||||
- cluster.id == cluster_origin.id
|
||||
- cluster|changed
|
||||
- cluster.name == "{{ cs_resource_prefix }}-cluster"
|
||||
- cluster.zone == "{{ cs_resource_prefix }}-zone"
|
||||
- cluster.allocation_state == "Enabled"
|
||||
- cluster_origin.hypervisor == "Simulator"
|
||||
|
||||
- name: test remove cluster idempotence
|
||||
cs_cluster:
|
||||
name: "{{ cs_resource_prefix }}-cluster"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
state: absent
|
||||
register: cluster
|
||||
- name: verify test remove cluster idempotence
|
||||
assert:
|
||||
that:
|
||||
- not cluster|changed
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
test_cs_configuration_storage: PS0
|
||||
test_cs_configuration_cluster: C0
|
||||
test_cs_configuration_account: admin
|
||||
test_cs_configuration_zone: Sandbox-simulator
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- test_cs_common
|
@ -0,0 +1,59 @@
|
||||
---
|
||||
- name: test configuration account
|
||||
cs_configuration:
|
||||
name: allow.public.user.templates
|
||||
account: "{{ test_cs_configuration_account }}"
|
||||
value: true
|
||||
register: config
|
||||
- name: verify test configuration storage
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
|
||||
- name: test update configuration account
|
||||
cs_configuration:
|
||||
name: allow.public.user.templates
|
||||
account: "{{ test_cs_configuration_account }}"
|
||||
value: false
|
||||
register: config
|
||||
- name: verify update configuration account
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "false"
|
||||
- config.name == "allow.public.user.templates"
|
||||
- config.scope == "account"
|
||||
- config.account == "{{ test_cs_configuration_account }}"
|
||||
|
||||
- name: test update configuration account idempotence
|
||||
cs_configuration:
|
||||
name: allow.public.user.templates
|
||||
account: "{{ test_cs_configuration_account }}"
|
||||
value: false
|
||||
register: config
|
||||
- name: verify update configuration account idempotence
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- not config|changed
|
||||
- config.value == "false"
|
||||
- config.name == "allow.public.user.templates"
|
||||
- config.scope == "account"
|
||||
- config.account == "{{ test_cs_configuration_account }}"
|
||||
|
||||
- name: test reset configuration account
|
||||
cs_configuration:
|
||||
name: allow.public.user.templates
|
||||
account: "{{ test_cs_configuration_account }}"
|
||||
value: true
|
||||
register: config
|
||||
- name: verify update configuration account
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "true"
|
||||
- config.name == "allow.public.user.templates"
|
||||
- config.scope == "account"
|
||||
- config.account == "{{ test_cs_configuration_account }}"
|
@ -0,0 +1,59 @@
|
||||
---
|
||||
- name: test configuration cluster
|
||||
cs_configuration:
|
||||
name: cpu.overprovisioning.factor
|
||||
cluster: "{{ test_cs_configuration_cluster }}"
|
||||
value: 1.0
|
||||
register: config
|
||||
- name: verify test configuration cluster
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
|
||||
- name: test update configuration cluster
|
||||
cs_configuration:
|
||||
name: cpu.overprovisioning.factor
|
||||
cluster: "{{ test_cs_configuration_cluster }}"
|
||||
value: 2.0
|
||||
register: config
|
||||
- name: verify update configuration cluster
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "2.0"
|
||||
- config.name == "cpu.overprovisioning.factor"
|
||||
- config.scope == "cluster"
|
||||
- config.cluster == "{{ test_cs_configuration_cluster }}"
|
||||
|
||||
- name: test update configuration cluster idempotence
|
||||
cs_configuration:
|
||||
name: cpu.overprovisioning.factor
|
||||
cluster: "{{ test_cs_configuration_cluster }}"
|
||||
value: 2.0
|
||||
register: config
|
||||
- name: verify update configuration cluster idempotence
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- not config|changed
|
||||
- config.value == "2.0"
|
||||
- config.name == "cpu.overprovisioning.factor"
|
||||
- config.scope == "cluster"
|
||||
- config.cluster == "{{ test_cs_configuration_cluster }}"
|
||||
|
||||
- name: test reset configuration cluster
|
||||
cs_configuration:
|
||||
name: cpu.overprovisioning.factor
|
||||
cluster: "{{ test_cs_configuration_cluster }}"
|
||||
value: 1.0
|
||||
register: config
|
||||
- name: verify reset configuration cluster
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "1.0"
|
||||
- config.name == "cpu.overprovisioning.factor"
|
||||
- config.scope == "cluster"
|
||||
- config.cluster == "{{ test_cs_configuration_cluster }}"
|
@ -0,0 +1,162 @@
|
||||
---
|
||||
- name: test fail if missing name
|
||||
cs_configuration:
|
||||
register: config
|
||||
ignore_errors: true
|
||||
- name: verify results of fail if missing arguments
|
||||
assert:
|
||||
that:
|
||||
- config|failed
|
||||
- "config.msg == 'missing required arguments: value,name'"
|
||||
|
||||
- name: test configuration
|
||||
cs_configuration:
|
||||
name: network.loadbalancer.haproxy.stats.visibility
|
||||
value: global
|
||||
register: config
|
||||
- name: verify test configuration
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
|
||||
- name: test update configuration string
|
||||
cs_configuration:
|
||||
name: network.loadbalancer.haproxy.stats.visibility
|
||||
value: all
|
||||
register: config
|
||||
- name: verify test update configuration string
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "all"
|
||||
- config.name == "network.loadbalancer.haproxy.stats.visibility"
|
||||
|
||||
- name: test update configuration string idempotence
|
||||
cs_configuration:
|
||||
name: network.loadbalancer.haproxy.stats.visibility
|
||||
value: all
|
||||
register: config
|
||||
- name: verify test update configuration string idempotence
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- not config|changed
|
||||
- config.value == "all"
|
||||
- config.name == "network.loadbalancer.haproxy.stats.visibility"
|
||||
|
||||
- name: test reset configuration string
|
||||
cs_configuration:
|
||||
name: network.loadbalancer.haproxy.stats.visibility
|
||||
value: global
|
||||
register: config
|
||||
- name: verify test reset configuration string
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "global"
|
||||
- config.name == "network.loadbalancer.haproxy.stats.visibility"
|
||||
|
||||
- name: test configuration
|
||||
cs_configuration:
|
||||
name: vmware.recycle.hung.wokervm
|
||||
value: false
|
||||
register: config
|
||||
- name: verify test configuration
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
|
||||
- name: test update configuration bool
|
||||
cs_configuration:
|
||||
name: vmware.recycle.hung.wokervm
|
||||
value: true
|
||||
register: config
|
||||
- name: verify test update configuration bool
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "true"
|
||||
- config.name == "vmware.recycle.hung.wokervm"
|
||||
|
||||
- name: test update configuration bool idempotence
|
||||
cs_configuration:
|
||||
name: vmware.recycle.hung.wokervm
|
||||
value: true
|
||||
register: config
|
||||
- name: verify test update configuration bool idempotence
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- not config|changed
|
||||
- config.value == "true"
|
||||
- config.name == "vmware.recycle.hung.wokervm"
|
||||
|
||||
- name: test reset configuration bool
|
||||
cs_configuration:
|
||||
name: vmware.recycle.hung.wokervm
|
||||
value: false
|
||||
register: config
|
||||
- name: verify test reset configuration bool
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "false"
|
||||
- config.name == "vmware.recycle.hung.wokervm"
|
||||
|
||||
- name: test configuration
|
||||
cs_configuration:
|
||||
name: agent.load.threshold
|
||||
value: 0.7
|
||||
register: config
|
||||
- name: verify test configuration
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
|
||||
- name: test update configuration float
|
||||
cs_configuration:
|
||||
name: agent.load.threshold
|
||||
value: 0.81
|
||||
register: config
|
||||
- name: verify update configuration float
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "0.81"
|
||||
- config.name == "agent.load.threshold"
|
||||
|
||||
- name: test update configuration float idempotence
|
||||
cs_configuration:
|
||||
name: agent.load.threshold
|
||||
value: 0.81
|
||||
register: config
|
||||
- name: verify update configuration float idempotence
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- not config|changed
|
||||
- config.value == "0.81"
|
||||
- config.name == "agent.load.threshold"
|
||||
|
||||
- name: reset configuration float
|
||||
cs_configuration:
|
||||
name: agent.load.threshold
|
||||
value: 0.7
|
||||
register: config
|
||||
- name: verify reset configuration float
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "0.7"
|
||||
- config.name == "agent.load.threshold"
|
||||
|
||||
- include: storage.yml
|
||||
- include: account.yml
|
||||
- include: zone.yml
|
||||
- include: cluster.yml
|
@ -0,0 +1,59 @@
|
||||
---
|
||||
- name: test configuration storage
|
||||
cs_configuration:
|
||||
name: storage.overprovisioning.factor
|
||||
storage: "{{ test_cs_configuration_storage }}"
|
||||
value: 2.0
|
||||
register: config
|
||||
- name: verify test configuration storage
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
|
||||
- name: test update configuration storage
|
||||
cs_configuration:
|
||||
name: storage.overprovisioning.factor
|
||||
storage: "{{ test_cs_configuration_storage }}"
|
||||
value: 3.0
|
||||
register: config
|
||||
- name: verify update configuration storage
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "3.0"
|
||||
- config.name == "storage.overprovisioning.factor"
|
||||
- config.scope == "storagepool"
|
||||
- config.storage == "{{ test_cs_configuration_storage }}"
|
||||
|
||||
- name: test update configuration storage idempotence
|
||||
cs_configuration:
|
||||
name: storage.overprovisioning.factor
|
||||
storage: "{{ test_cs_configuration_storage }}"
|
||||
value: 3.0
|
||||
register: config
|
||||
- name: verify update configuration storage idempotence
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- not config|changed
|
||||
- config.value == "3.0"
|
||||
- config.name == "storage.overprovisioning.factor"
|
||||
- config.scope == "storagepool"
|
||||
- config.storage == "{{ test_cs_configuration_storage }}"
|
||||
|
||||
- name: test reset configuration storage
|
||||
cs_configuration:
|
||||
name: storage.overprovisioning.factor
|
||||
storage: "{{ test_cs_configuration_storage }}"
|
||||
value: 2.0
|
||||
register: config
|
||||
- name: verify reset configuration storage
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "2.0"
|
||||
- config.name == "storage.overprovisioning.factor"
|
||||
- config.scope == "storagepool"
|
||||
- config.storage == "{{ test_cs_configuration_storage }}"
|
@ -0,0 +1,59 @@
|
||||
---
|
||||
- name: test configuration zone
|
||||
cs_configuration:
|
||||
name: use.external.dns
|
||||
zone: "{{ test_cs_configuration_zone }}"
|
||||
value: false
|
||||
register: config
|
||||
- name: verify test configuration zone
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
|
||||
- name: test update configuration zone
|
||||
cs_configuration:
|
||||
name: use.external.dns
|
||||
zone: "{{ test_cs_configuration_zone }}"
|
||||
value: true
|
||||
register: config
|
||||
- name: verify update configuration zone
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "true"
|
||||
- config.name == "use.external.dns"
|
||||
- config.scope == "zone"
|
||||
- config.zone == "{{ test_cs_configuration_zone }}"
|
||||
|
||||
- name: test update configuration zone idempotence
|
||||
cs_configuration:
|
||||
name: use.external.dns
|
||||
zone: "{{ test_cs_configuration_zone }}"
|
||||
value: true
|
||||
register: config
|
||||
- name: verify update configuration zone idempotence
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- not config|changed
|
||||
- config.value == "true"
|
||||
- config.name == "use.external.dns"
|
||||
- config.scope == "zone"
|
||||
- config.zone == "{{ test_cs_configuration_zone }}"
|
||||
|
||||
- name: test reset configuration zone
|
||||
cs_configuration:
|
||||
name: use.external.dns
|
||||
zone: "{{ test_cs_configuration_zone }}"
|
||||
value: false
|
||||
register: config
|
||||
- name: verify reset configuration zone
|
||||
assert:
|
||||
that:
|
||||
- config|success
|
||||
- config|changed
|
||||
- config.value == "false"
|
||||
- config.name == "use.external.dns"
|
||||
- config.scope == "zone"
|
||||
- config.zone == "{{ test_cs_configuration_zone }}"
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
test_cs_instance_template: CentOS 5.3(64-bit) no GUI (Simulator)
|
||||
test_cs_instance_offering_1: Small Instance
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- test_cs_common
|
@ -0,0 +1,55 @@
|
||||
---
|
||||
- name: setup ssh key
|
||||
cs_sshkeypair: name={{ cs_resource_prefix }}-sshkey
|
||||
register: sshkey
|
||||
- name: verify setup ssh key
|
||||
assert:
|
||||
that:
|
||||
- sshkey|success
|
||||
|
||||
- name: setup affinity group
|
||||
cs_affinitygroup: name={{ cs_resource_prefix }}-ag
|
||||
register: ag
|
||||
- name: verify setup affinity group
|
||||
assert:
|
||||
that:
|
||||
- ag|success
|
||||
|
||||
- name: setup security group
|
||||
cs_securitygroup: name={{ cs_resource_prefix }}-sg
|
||||
register: sg
|
||||
- name: verify setup security group
|
||||
assert:
|
||||
that:
|
||||
- sg|success
|
||||
|
||||
- name: setup instance
|
||||
cs_instance:
|
||||
name: "{{ cs_resource_prefix }}-vm"
|
||||
template: "{{ test_cs_instance_template }}"
|
||||
service_offering: "{{ test_cs_instance_offering_1 }}"
|
||||
affinity_group: "{{ cs_resource_prefix }}-ag"
|
||||
security_group: "{{ cs_resource_prefix }}-sg"
|
||||
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
||||
tags: []
|
||||
register: instance
|
||||
- name: verify create instance
|
||||
assert:
|
||||
that:
|
||||
- instance|success
|
||||
|
||||
- name: test instance facts
|
||||
cs_instance_facts:
|
||||
name: "{{ cs_resource_prefix }}-vm"
|
||||
register: instance_facts
|
||||
- name: verify test instance facts
|
||||
assert:
|
||||
that:
|
||||
- instance_facts|success
|
||||
- not instance_facts|changed
|
||||
- cloudstack_instance.id == instance.id
|
||||
- cloudstack_instance.domain == instance.domain
|
||||
- cloudstack_instance.account == instance.account
|
||||
- cloudstack_instance.zone == instance.zone
|
||||
- cloudstack_instance.name == instance.name
|
||||
- cloudstack_instance.service_offering == instance.service_offering
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- test_cs_common
|
@ -0,0 +1,210 @@
|
||||
---
|
||||
- name: setup pod is absent
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
state: absent
|
||||
register: pod
|
||||
- name: verify setup pod is absent
|
||||
assert:
|
||||
that:
|
||||
- pod|success
|
||||
|
||||
- name: setup zone is present
|
||||
cs_zone:
|
||||
name: "{{ cs_resource_prefix }}-zone"
|
||||
dns1: 8.8.8.8
|
||||
dns2: 8.8.4.4
|
||||
network_type: basic
|
||||
register: zone
|
||||
- name: verify setup zone is present
|
||||
assert:
|
||||
that:
|
||||
- zone|success
|
||||
|
||||
- name: test fail if missing name
|
||||
cs_pod:
|
||||
register: pod
|
||||
ignore_errors: true
|
||||
- name: verify results of fail if missing name
|
||||
assert:
|
||||
that:
|
||||
- pod|failed
|
||||
- "pod.msg == 'missing required arguments: name'"
|
||||
|
||||
- name: test create pod
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
start_ip: 10.100.10.101
|
||||
gateway: 10.100.10.1
|
||||
netmask: 255.255.255.0
|
||||
register: pod_origin
|
||||
- name: verify test create pod
|
||||
assert:
|
||||
that:
|
||||
- pod_origin|changed
|
||||
- pod_origin.allocation_state == "Enabled"
|
||||
- pod_origin.start_ip == "10.100.10.101"
|
||||
- pod_origin.end_ip == "10.100.10.254"
|
||||
- pod_origin.gateway == "10.100.10.1"
|
||||
- pod_origin.netmask == "255.255.255.0"
|
||||
- pod_origin.zone == "{{ cs_resource_prefix }}-zone"
|
||||
|
||||
- name: test create pod idempotence
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
start_ip: 10.100.10.101
|
||||
gateway: 10.100.10.1
|
||||
netmask: 255.255.255.0
|
||||
register: pod
|
||||
- name: verify test create pod idempotence
|
||||
assert:
|
||||
that:
|
||||
- not pod|changed
|
||||
- pod.allocation_state == "Enabled"
|
||||
- pod.start_ip == "10.100.10.101"
|
||||
- pod.end_ip == "10.100.10.254"
|
||||
- pod.gateway == "10.100.10.1"
|
||||
- pod.netmask == "255.255.255.0"
|
||||
- pod.zone == "{{ cs_resource_prefix }}-zone"
|
||||
|
||||
- name: test update pod
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
start_ip: 10.100.10.102
|
||||
gateway: 10.100.10.1
|
||||
netmask: 255.255.255.0
|
||||
register: pod
|
||||
- name: verify test update pod
|
||||
assert:
|
||||
that:
|
||||
- pod|changed
|
||||
- pod.allocation_state == "Enabled"
|
||||
- pod.start_ip == "10.100.10.102"
|
||||
- pod.end_ip == "10.100.10.254"
|
||||
- pod.gateway == "10.100.10.1"
|
||||
- pod.netmask == "255.255.255.0"
|
||||
- pod.zone == "{{ cs_resource_prefix }}-zone"
|
||||
|
||||
- name: test update pod idempotence
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
start_ip: 10.100.10.102
|
||||
gateway: 10.100.10.1
|
||||
netmask: 255.255.255.0
|
||||
register: pod
|
||||
- name: verify test update pod idempotence
|
||||
assert:
|
||||
that:
|
||||
- not pod|changed
|
||||
- pod.allocation_state == "Enabled"
|
||||
- pod.start_ip == "10.100.10.102"
|
||||
- pod.end_ip == "10.100.10.254"
|
||||
- pod.gateway == "10.100.10.1"
|
||||
- pod.netmask == "255.255.255.0"
|
||||
- pod.zone == "{{ cs_resource_prefix }}-zone"
|
||||
|
||||
- name: test disable pod
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
state: disabled
|
||||
register: pod
|
||||
- name: verify test enable pod
|
||||
assert:
|
||||
that:
|
||||
- pod|changed
|
||||
- pod.allocation_state == "Disabled"
|
||||
- pod.id == pod_origin.id
|
||||
- pod.start_ip == "10.100.10.102"
|
||||
- pod.end_ip == "10.100.10.254"
|
||||
- pod.gateway == "10.100.10.1"
|
||||
- pod.netmask == "255.255.255.0"
|
||||
- pod.zone == "{{ cs_resource_prefix }}-zone"
|
||||
|
||||
- name: test disable pod idempotence
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
state: disabled
|
||||
register: pod
|
||||
- name: verify test enable pod idempotence
|
||||
assert:
|
||||
that:
|
||||
- not pod|changed
|
||||
- pod.allocation_state == "Disabled"
|
||||
- pod.id == pod_origin.id
|
||||
- pod.start_ip == "10.100.10.102"
|
||||
- pod.end_ip == "10.100.10.254"
|
||||
- pod.gateway == "10.100.10.1"
|
||||
- pod.netmask == "255.255.255.0"
|
||||
- pod.zone == "{{ cs_resource_prefix }}-zone"
|
||||
|
||||
- name: test enable pod
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
state: enabled
|
||||
register: pod
|
||||
- name: verify test disable pod
|
||||
assert:
|
||||
that:
|
||||
- pod|changed
|
||||
- pod.allocation_state == "Enabled"
|
||||
- pod.id == pod_origin.id
|
||||
- pod.start_ip == "10.100.10.102"
|
||||
- pod.end_ip == "10.100.10.254"
|
||||
- pod.gateway == "10.100.10.1"
|
||||
- pod.netmask == "255.255.255.0"
|
||||
- pod.zone == "{{ cs_resource_prefix }}-zone"
|
||||
|
||||
|
||||
- name: test enable pod idempotence
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
state: enabled
|
||||
register: pod
|
||||
- name: verify test enabled pod idempotence
|
||||
assert:
|
||||
that:
|
||||
- not pod|changed
|
||||
- pod.allocation_state == "Enabled"
|
||||
- pod.id == pod_origin.id
|
||||
- pod.start_ip == "10.100.10.102"
|
||||
- pod.end_ip == "10.100.10.254"
|
||||
- pod.gateway == "10.100.10.1"
|
||||
- pod.netmask == "255.255.255.0"
|
||||
- pod.zone == "{{ cs_resource_prefix }}-zone"
|
||||
|
||||
- name: test absent pod
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
state: absent
|
||||
register: pod
|
||||
- name: verify test create pod
|
||||
assert:
|
||||
that:
|
||||
- pod|changed
|
||||
- pod.id == pod_origin.id
|
||||
- pod.allocation_state == "Enabled"
|
||||
- pod.start_ip == "10.100.10.102"
|
||||
- pod.end_ip == "10.100.10.254"
|
||||
- pod.gateway == "10.100.10.1"
|
||||
- pod.netmask == "255.255.255.0"
|
||||
- pod.zone == "{{ cs_resource_prefix }}-zone"
|
||||
|
||||
- name: test absent pod idempotence
|
||||
cs_pod:
|
||||
name: "{{ cs_resource_prefix }}-pod"
|
||||
zone: "{{ cs_resource_prefix }}-zone"
|
||||
state: absent
|
||||
register: pod
|
||||
- name: verify test absent pod idempotence
|
||||
assert:
|
||||
that:
|
||||
- not pod|changed
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- test_cs_common
|
@ -0,0 +1,76 @@
|
||||
---
|
||||
- name: setup cpu limits account
|
||||
cs_resourcelimit:
|
||||
type: cpu
|
||||
limit: 20
|
||||
account: "{{ cs_resource_prefix }}_user"
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify setup cpu limits account
|
||||
assert:
|
||||
that:
|
||||
- rl|success
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.account == "{{ cs_resource_prefix }}_user"
|
||||
- rl.limit == 20
|
||||
- rl.resource_type == "cpu"
|
||||
|
||||
- name: set cpu limits for domain
|
||||
cs_resourcelimit:
|
||||
type: cpu
|
||||
limit: 12
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify set cpu limits for domain
|
||||
assert:
|
||||
that:
|
||||
- rl|changed
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.limit == 12
|
||||
- rl.resource_type == "cpu"
|
||||
|
||||
- name: set cpu limits for domain idempotence
|
||||
cs_resourcelimit:
|
||||
type: cpu
|
||||
limit: 12
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify set cpu limits for domain
|
||||
assert:
|
||||
that:
|
||||
- not rl|changed
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.limit == 12
|
||||
- rl.resource_type == "cpu"
|
||||
|
||||
- name: set cpu limits for account
|
||||
cs_resourcelimit:
|
||||
type: cpu
|
||||
limit: 10
|
||||
account: "{{ cs_resource_prefix }}_user"
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify set cpu limits for account
|
||||
assert:
|
||||
that:
|
||||
- rl|changed
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.account == "{{ cs_resource_prefix }}_user"
|
||||
- rl.limit == 10
|
||||
- rl.resource_type == "cpu"
|
||||
|
||||
- name: set cpu limits for account idempotence
|
||||
cs_resourcelimit:
|
||||
type: cpu
|
||||
limit: 10
|
||||
account: "{{ cs_resource_prefix }}_user"
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify set cpu limits for account idempotence
|
||||
assert:
|
||||
that:
|
||||
- not rl|changed
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.account == "{{ cs_resource_prefix }}_user"
|
||||
- rl.limit == 10
|
||||
- rl.resource_type == "cpu"
|
@ -0,0 +1,76 @@
|
||||
---
|
||||
- name: setup instance limits account
|
||||
cs_resourcelimit:
|
||||
type: instance
|
||||
limit: 20
|
||||
account: "{{ cs_resource_prefix }}_user"
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify setup instance limits account
|
||||
assert:
|
||||
that:
|
||||
- rl|success
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.account == "{{ cs_resource_prefix }}_user"
|
||||
- rl.limit == 20
|
||||
- rl.resource_type == "instance"
|
||||
|
||||
- name: set instance limits for domain
|
||||
cs_resourcelimit:
|
||||
type: instance
|
||||
limit: 12
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify set instance limits for domain
|
||||
assert:
|
||||
that:
|
||||
- rl|changed
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.limit == 12
|
||||
- rl.resource_type == "instance"
|
||||
|
||||
- name: set instance limits for domain idempotence
|
||||
cs_resourcelimit:
|
||||
type: instance
|
||||
limit: 12
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify set instance limits for domain
|
||||
assert:
|
||||
that:
|
||||
- not rl|changed
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.limit == 12
|
||||
- rl.resource_type == "instance"
|
||||
|
||||
- name: set instance limits for account
|
||||
cs_resourcelimit:
|
||||
type: instance
|
||||
limit: 10
|
||||
account: "{{ cs_resource_prefix }}_user"
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify set instance limits for account
|
||||
assert:
|
||||
that:
|
||||
- rl|changed
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.account == "{{ cs_resource_prefix }}_user"
|
||||
- rl.limit == 10
|
||||
- rl.resource_type == "instance"
|
||||
|
||||
- name: set instance limits for account idempotence
|
||||
cs_resourcelimit:
|
||||
type: instance
|
||||
limit: 10
|
||||
account: "{{ cs_resource_prefix }}_user"
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify set instance limits for account idempotence
|
||||
assert:
|
||||
that:
|
||||
- not rl|changed
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.account == "{{ cs_resource_prefix }}_user"
|
||||
- rl.limit == 10
|
||||
- rl.resource_type == "instance"
|
@ -0,0 +1,61 @@
|
||||
---
|
||||
- name: setup domain
|
||||
cs_domain: path={{ cs_resource_prefix }}-domain
|
||||
register: dom
|
||||
- name: verify setup domain
|
||||
assert:
|
||||
that:
|
||||
- dom|success
|
||||
|
||||
- name: setup account
|
||||
cs_account:
|
||||
name: "{{ cs_resource_prefix }}_user"
|
||||
username: "{{ cs_resource_prefix }}_username"
|
||||
password: "{{ cs_resource_prefix }}_password"
|
||||
last_name: "{{ cs_resource_prefix }}_last_name"
|
||||
first_name: "{{ cs_resource_prefix }}_first_name"
|
||||
email: "{{ cs_resource_prefix }}@example.com"
|
||||
network_domain: "{{ cs_resource_prefix }}-local"
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: acc
|
||||
- name: verify setup account
|
||||
assert:
|
||||
that:
|
||||
- acc|success
|
||||
|
||||
- name: test failed unkonwn type
|
||||
cs_resourcelimit:
|
||||
type: unkonwn
|
||||
limit: 20
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
ignore_errors: yes
|
||||
- name: verify test failed unkonwn type
|
||||
assert:
|
||||
that:
|
||||
- rl|failed
|
||||
|
||||
- name: test failed missing type
|
||||
cs_resourcelimit:
|
||||
register: rl
|
||||
ignore_errors: yes
|
||||
- name: verify test failed missing type
|
||||
assert:
|
||||
that:
|
||||
- rl|failed
|
||||
|
||||
- name: setup resource limits domain
|
||||
cs_resourcelimit:
|
||||
type: instance
|
||||
limit: 20
|
||||
domain: "{{ cs_resource_prefix }}-domain"
|
||||
register: rl
|
||||
- name: verify setup resource limits domain
|
||||
assert:
|
||||
that:
|
||||
- rl|success
|
||||
- rl.domain == "{{ cs_resource_prefix }}-domain"
|
||||
- rl.limit == 20
|
||||
|
||||
- include: instance.yml
|
||||
- include: cpu.yml
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
test_cs_instance_1: "{{ cs_resource_prefix }}-vm1"
|
||||
test_cs_instance_2: "{{ cs_resource_prefix }}-vm2"
|
||||
test_cs_instance_template: CentOS 5.3(64-bit) no GUI (Simulator)
|
||||
test_cs_instance_offering_1: Small Instance
|
||||
test_cs_disk_offering_1: Custom
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- test_cs_common
|
@ -0,0 +1,215 @@
|
||||
---
|
||||
- name: setup
|
||||
cs_volume: name={{ cs_resource_prefix }}_vol state=absent
|
||||
register: vol
|
||||
- name: verify setup
|
||||
assert:
|
||||
that:
|
||||
- vol|success
|
||||
|
||||
- name: setup instance 1
|
||||
cs_instance:
|
||||
name: "{{ test_cs_instance_1 }}"
|
||||
template: "{{ test_cs_instance_template }}"
|
||||
service_offering: "{{ test_cs_instance_offering_1 }}"
|
||||
register: instance
|
||||
- name: verify create instance
|
||||
assert:
|
||||
that:
|
||||
- instance|success
|
||||
|
||||
- name: setup instance 2
|
||||
cs_instance:
|
||||
name: "{{ test_cs_instance_2 }}"
|
||||
template: "{{ test_cs_instance_template }}"
|
||||
service_offering: "{{ test_cs_instance_offering_1 }}"
|
||||
register: instance
|
||||
- name: verify create instance
|
||||
assert:
|
||||
that:
|
||||
- instance|success
|
||||
|
||||
- name: test fail if missing name
|
||||
action: cs_volume
|
||||
register: vol
|
||||
ignore_errors: true
|
||||
- name: verify results of fail if missing name
|
||||
assert:
|
||||
that:
|
||||
- vol|failed
|
||||
- "vol.msg == 'missing required arguments: name'"
|
||||
|
||||
- name: test create volume
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
||||
size: 20
|
||||
register: vol
|
||||
- name: verify results test create volume
|
||||
assert:
|
||||
that:
|
||||
- vol|changed
|
||||
- vol.size == 20 * 1024 ** 3
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
|
||||
- name: test create volume idempotence
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
||||
size: 20
|
||||
register: vol
|
||||
- name: verify results test create volume idempotence
|
||||
assert:
|
||||
that:
|
||||
- not vol|changed
|
||||
- vol.size == 20 * 1024 ** 3
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
|
||||
- name: test shrink volume
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
||||
size: 10
|
||||
shrink_ok: yes
|
||||
register: vol
|
||||
- name: verify results test create volume
|
||||
assert:
|
||||
that:
|
||||
- vol|changed
|
||||
- vol.size == 10 * 1024 ** 3
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
|
||||
- name: test shrink volume idempotence
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
||||
size: 10
|
||||
shrink_ok: yes
|
||||
register: vol
|
||||
- name: verify results test create volume
|
||||
assert:
|
||||
that:
|
||||
- not vol|changed
|
||||
- vol.size == 10 * 1024 ** 3
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
|
||||
- name: test attach volume
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
vm: "{{ test_cs_instance_1 }}"
|
||||
state: attached
|
||||
register: vol
|
||||
- name: verify results test attach volume
|
||||
assert:
|
||||
that:
|
||||
- vol|changed
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
- vol.vm == "{{ test_cs_instance_1 }}"
|
||||
- vol.attached is defined
|
||||
|
||||
- name: test attach volume idempotence
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
vm: "{{ test_cs_instance_1 }}"
|
||||
state: attached
|
||||
register: vol
|
||||
- name: verify results test attach volume idempotence
|
||||
assert:
|
||||
that:
|
||||
- not vol|changed
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
- vol.vm == "{{ test_cs_instance_1 }}"
|
||||
- vol.attached is defined
|
||||
|
||||
- name: test attach attached volume to another vm
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
vm: "{{ test_cs_instance_2 }}"
|
||||
state: attached
|
||||
register: vol
|
||||
- name: verify results test attach attached volume to another vm
|
||||
assert:
|
||||
that:
|
||||
- vol|changed
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
- vol.vm == "{{ test_cs_instance_2 }}"
|
||||
- vol.attached is defined
|
||||
|
||||
- name: test attach attached volume to another vm idempotence
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
vm: "{{ test_cs_instance_2 }}"
|
||||
state: attached
|
||||
register: vol
|
||||
- name: verify results test attach attached volume to another vm idempotence
|
||||
assert:
|
||||
that:
|
||||
- not vol|changed
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
- vol.vm == "{{ test_cs_instance_2 }}"
|
||||
- vol.attached is defined
|
||||
|
||||
- name: test detach volume
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
state: detached
|
||||
register: vol
|
||||
- name: verify results test detach volume
|
||||
assert:
|
||||
that:
|
||||
- vol|changed
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
- vol.attached is undefined
|
||||
|
||||
- name: test detach volume idempotence
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
state: detached
|
||||
register: vol
|
||||
- name: verify results test detach volume idempotence
|
||||
assert:
|
||||
that:
|
||||
- not vol|changed
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
- vol.attached is undefined
|
||||
|
||||
- name: test delete volume
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
state: absent
|
||||
register: vol
|
||||
- name: verify results test create volume
|
||||
assert:
|
||||
that:
|
||||
- vol|changed
|
||||
- vol.name == "{{ cs_resource_prefix }}_vol"
|
||||
|
||||
- name: test delete volume idempotence
|
||||
cs_volume:
|
||||
name: "{{ cs_resource_prefix }}_vol"
|
||||
state: absent
|
||||
register: vol
|
||||
- name: verify results test delete volume idempotence
|
||||
assert:
|
||||
that:
|
||||
- not vol|changed
|
||||
|
||||
- name: cleanup instance 1
|
||||
cs_instance:
|
||||
name: "{{ test_cs_instance_1 }}"
|
||||
state: absent
|
||||
register: instance
|
||||
- name: verify create instance
|
||||
assert:
|
||||
that:
|
||||
- instance|success
|
||||
|
||||
- name: cleanup instance 2
|
||||
cs_instance:
|
||||
name: "{{ test_cs_instance_2 }}"
|
||||
state: absent
|
||||
register: instance
|
||||
- name: verify create instance
|
||||
assert:
|
||||
that:
|
||||
- instance|success
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
- prepare_win_tests
|
||||
|
@ -0,0 +1,133 @@
|
||||
# test code for the win_regmerge module
|
||||
# (c) 2014, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# clear the area of the registry we are using for tests
|
||||
- name: remove setting
|
||||
win_regedit:
|
||||
key: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp'
|
||||
state: absent
|
||||
|
||||
# copy over some registry files to work with
|
||||
- name: copy over some registry files to work with
|
||||
win_copy: src={{item}} dest={{win_output_dir}}\\{{item}}
|
||||
with_items:
|
||||
- settings1.reg
|
||||
- settings2.reg
|
||||
- settings3.reg
|
||||
|
||||
# test 1 - basic test of changed behaviour
|
||||
# merge in REG_SZ
|
||||
- name: test 1 merge in a setting
|
||||
win_regmerge:
|
||||
path: "{{win_output_dir}}\\settings1.reg"
|
||||
register: merge11_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "merge11_result.changed == true"
|
||||
|
||||
# re run the merge
|
||||
- name: test 1 merge in the setting again
|
||||
win_regmerge:
|
||||
path: "{{win_output_dir}}\\settings1.reg"
|
||||
register: merge12_result
|
||||
|
||||
# without a compare to key, should allways report changed
|
||||
- assert:
|
||||
that:
|
||||
- "merge12_result.changed == true"
|
||||
# assert changed false
|
||||
|
||||
# prune reg key
|
||||
- name: test 1 remove setting
|
||||
win_regedit:
|
||||
key: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp'
|
||||
state: absent
|
||||
|
||||
#
|
||||
# test 2, observe behaviour when compare_to param is set
|
||||
#
|
||||
- name: test 2 merge in a setting
|
||||
win_regmerge:
|
||||
path: "{{win_output_dir}}\\settings1.reg"
|
||||
compare_to: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp\Moosic\ILikeToMooveIt'
|
||||
register: merge21_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "merge21_result.changed == true"
|
||||
|
||||
# re run the merge
|
||||
- name: test 2 merge in the setting again but with compare_key
|
||||
win_regmerge:
|
||||
path: "{{win_output_dir}}\\settings1.reg"
|
||||
compare_to: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp\Moosic\ILikeToMooveIt'
|
||||
register: merge22_result
|
||||
|
||||
# with a compare to key, should now report not changed
|
||||
- assert:
|
||||
that:
|
||||
- "merge22_result.changed == false"
|
||||
# assert changed false
|
||||
|
||||
# prune the contents of the registry from the parent of the compare key downwards
|
||||
- name: test 2 clean up remove setting
|
||||
win_regedit:
|
||||
key: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp'
|
||||
state: absent
|
||||
|
||||
# test 3 merge in more complex settings
|
||||
- name: test 3 merge in a setting
|
||||
win_regmerge:
|
||||
path: "{{win_output_dir}}\\settings3.reg"
|
||||
compare_to: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp\Moo Monitor'
|
||||
register: merge31_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "merge31_result.changed == true"
|
||||
|
||||
# re run the merge
|
||||
- name: test 3 merge in the setting again but with compare_key check
|
||||
win_regmerge:
|
||||
path: "{{win_output_dir}}\\settings3.reg"
|
||||
compare_to: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp\Moo Monitor'
|
||||
register: merge32_result
|
||||
|
||||
# with a compare to key, should now report not changed
|
||||
- assert:
|
||||
that:
|
||||
- "merge32_result.changed == false"
|
||||
# assert changed false
|
||||
|
||||
# prune the contents of the registry from the compare key downwards
|
||||
- name: test 3 clean up remove setting
|
||||
win_regedit:
|
||||
key: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp'
|
||||
state: absent
|
||||
|
||||
# clean up registry files
|
||||
|
||||
- name: clean up registry files
|
||||
win_file: path={{win_output_dir}}\\{{item}} state=absent
|
||||
with_items:
|
||||
- settings1.reg
|
||||
- settings2.reg
|
||||
- settings3.reg
|
||||
|
||||
# END OF win_regmerge tests
|
@ -0,0 +1,4 @@
|
||||
#jinja2: newline_sequence:'\r\n'
|
||||
{{ templated_var }}
|
||||
{{ templated_var }}
|
||||
{{ templated_var }}
|
@ -0,0 +1 @@
|
||||
templated_var: templated_var_loaded
|
@ -0,0 +1,56 @@
|
||||
[local]
|
||||
local-pipelining ansible_ssh_pipelining=true
|
||||
local-no-pipelining ansible_ssh_pipelining=false
|
||||
[local:vars]
|
||||
ansible_host=localhost
|
||||
ansible_connection=local
|
||||
|
||||
[chroot]
|
||||
chroot-pipelining ansible_ssh_pipelining=true
|
||||
chroot-no-pipelining ansible_ssh_pipelining=false
|
||||
[chroot:vars]
|
||||
ansible_host=/
|
||||
ansible_connection=chroot
|
||||
|
||||
[docker]
|
||||
docker-pipelining ansible_ssh_pipelining=true
|
||||
docker-no-pipelining ansible_ssh_pipelining=false
|
||||
[docker:vars]
|
||||
ansible_host=ubuntu-latest
|
||||
ansible_connection=docker
|
||||
|
||||
[libvirt_lxc]
|
||||
libvirt_lxc-pipelining ansible_ssh_pipelining=true
|
||||
libvirt_lxc-no-pipelining ansible_ssh_pipelining=false
|
||||
[libvirt_lxc:vars]
|
||||
ansible_host=lv-ubuntu-wily-amd64
|
||||
ansible_connection=libvirt_lxc
|
||||
|
||||
[jail]
|
||||
jail-pipelining ansible_ssh_pipelining=true
|
||||
jail-no-pipelining ansible_ssh_pipelining=false
|
||||
[jail:vars]
|
||||
ansible_host=freebsd_10_2
|
||||
ansible_connection=jail
|
||||
ansible_python_interpreter=/usr/local/bin/python
|
||||
|
||||
[ssh]
|
||||
ssh-pipelining ansible_ssh_pipelining=true
|
||||
ssh-no-pipelining ansible_ssh_pipelining=false
|
||||
[ssh:vars]
|
||||
ansible_host=localhost
|
||||
ansible_connection=ssh
|
||||
|
||||
[paramiko_ssh]
|
||||
paramiko_ssh-pipelining ansible_ssh_pipelining=true
|
||||
paramiko_ssh-no-pipelining ansible_ssh_pipelining=false
|
||||
[paramiko_ssh:vars]
|
||||
ansible_host=localhost
|
||||
ansible_connection=paramiko_ssh
|
||||
|
||||
[skip-during-build:children]
|
||||
docker
|
||||
libvirt_lxc
|
||||
jail
|
||||
ssh
|
||||
paramiko_ssh
|
@ -0,0 +1,37 @@
|
||||
- hosts: all
|
||||
gather_facts: no
|
||||
serial: 1
|
||||
tasks:
|
||||
|
||||
### raw with unicode arg and output
|
||||
|
||||
- name: raw with unicode arg and output
|
||||
raw: echo 汉语
|
||||
register: command
|
||||
- name: check output of raw with unicode arg and output
|
||||
assert: { that: "'汉语' in command.stdout" }
|
||||
|
||||
### copy local file with unicode filename and content
|
||||
|
||||
- name: create local file with unicode filename and content
|
||||
local_action: lineinfile dest=/tmp/ansible-local-汉语/汉语.txt create=true line=汉语
|
||||
- name: remove remote file with unicode filename and content
|
||||
file: path=/tmp/ansible-remote-汉语/汉语.txt state=absent
|
||||
- name: create remote directory with unicode name
|
||||
file: path=/tmp/ansible-remote-汉语 state=directory
|
||||
- name: copy local file with unicode filename and content
|
||||
copy: src=/tmp/ansible-local-汉语/汉语.txt dest=/tmp/ansible-remote-汉语/汉语.txt
|
||||
|
||||
### fetch remote file with unicode filename and content
|
||||
|
||||
- name: remove local file with unicode filename and content
|
||||
local_action: file path=/tmp/ansible-local-汉语/汉语.txt state=absent
|
||||
- name: fetch remote file with unicode filename and content
|
||||
fetch: src=/tmp/ansible-remote-汉语/汉语.txt dest=/tmp/ansible-local-汉语/汉语.txt fail_on_missing=true validate_checksum=true flat=true
|
||||
|
||||
### remove local and remote temp files
|
||||
|
||||
- name: remove local temp file
|
||||
local_action: file path=/tmp/ansible-local-汉语 state=absent
|
||||
- name: remove remote temp file
|
||||
file: path=/tmp/ansible-remote-汉语 state=absent
|
@ -0,0 +1,133 @@
|
||||
---
|
||||
|
||||
- hosts: facthost0
|
||||
tags: [ 'fact_min' ]
|
||||
connection: local
|
||||
gather_subset: "all"
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- setup:
|
||||
register: facts
|
||||
- debug: var=facts
|
||||
- name: Test that retrieving all facts works
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_user_id|default("UNDEF_MIN") }}" != "UNDEF_MIN"'
|
||||
- '"{{ ansible_interfaces|default("UNDEF_NET") }}" != "UNDEF_NET"'
|
||||
- '"{{ ansible_mounts|default("UNDEF_HW") }}" != "UNDEF_HW"'
|
||||
- '"{{ ansible_virtualization_role|default("UNDEF_VIRT") }}" != "UNDEF_VIRT"'
|
||||
|
||||
- hosts: facthost1
|
||||
tags: [ 'fact_min' ]
|
||||
connection: local
|
||||
gather_subset: "!all"
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Test that only retrieving minimal facts work
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_user_id|default("UNDEF_MIN") }}" != "UNDEF_MIN"'
|
||||
- '"{{ ansible_interfaces|default("UNDEF_NET") }}" == "UNDEF_NET"'
|
||||
- '"{{ ansible_mounts|default("UNDEF_HW") }}" == "UNDEF_HW"'
|
||||
- '"{{ ansible_virtualization_role|default("UNDEF_VIRT") }}" == "UNDEF_VIRT"'
|
||||
|
||||
- hosts: facthost2
|
||||
tags: [ 'fact_network' ]
|
||||
connection: local
|
||||
gather_subset: "network"
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Test that retrieving network facts work
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_user_id|default("UNDEF_MIN") }}" != "UNDEF_MIN"'
|
||||
- '"{{ ansible_interfaces|default("UNDEF_NET") }}" != "UNDEF_NET"'
|
||||
- '"{{ ansible_mounts|default("UNDEF_HW") }}" == "UNDEF_HW"'
|
||||
- '"{{ ansible_virtualization_role|default("UNDEF_VIRT") }}" == "UNDEF_VIRT"'
|
||||
|
||||
- hosts: facthost3
|
||||
tags: [ 'fact_hardware' ]
|
||||
connection: local
|
||||
gather_subset: "hardware"
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Test that retrieving hardware facts work
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_user_id|default("UNDEF_MIN") }}" != "UNDEF_MIN"'
|
||||
- '"{{ ansible_interfaces|default("UNDEF_NET") }}" == "UNDEF_NET"'
|
||||
- '"{{ ansible_mounts|default("UNDEF_HW") }}" != "UNDEF_HW"'
|
||||
- '"{{ ansible_virtualization_role|default("UNDEF_VIRT") }}" == "UNDEF_VIRT"'
|
||||
|
||||
- hosts: facthost4
|
||||
tags: [ 'fact_virtual' ]
|
||||
connection: local
|
||||
gather_subset: "virtual"
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Test that retrieving virtualization facts work
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_user_id|default("UNDEF_MIN") }}" != "UNDEF_MIN"'
|
||||
- '"{{ ansible_interfaces|default("UNDEF_NET") }}" == "UNDEF_NET"'
|
||||
- '"{{ ansible_mounts|default("UNDEF_HW") }}" == "UNDEF_HW"'
|
||||
- '"{{ ansible_virtualization_role|default("UNDEF_VIRT") }}" != "UNDEF_VIRT"'
|
||||
|
||||
- hosts: facthost5
|
||||
tags: [ 'fact_comma_string' ]
|
||||
connection: local
|
||||
gather_subset: "virtual,network"
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Test that retrieving virtualization and network as a string works
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_user_id|default("UNDEF_MIN") }}" != "UNDEF_MIN"'
|
||||
- '"{{ ansible_interfaces|default("UNDEF_NET") }}" != "UNDEF_NET"'
|
||||
- '"{{ ansible_mounts|default("UNDEF_HW") }}" == "UNDEF_HW"'
|
||||
- '"{{ ansible_virtualization_role|default("UNDEF_VIRT") }}" != "UNDEF_VIRT"'
|
||||
|
||||
- hosts: facthost6
|
||||
tags: [ 'fact_yaml_list' ]
|
||||
connection: local
|
||||
gather_subset:
|
||||
- virtual
|
||||
- network
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Test that retrieving virtualization and network as a string works
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_user_id|default("UNDEF_MIN") }}" != "UNDEF_MIN"'
|
||||
- '"{{ ansible_interfaces|default("UNDEF_NET") }}" != "UNDEF_NET"'
|
||||
- '"{{ ansible_mounts|default("UNDEF_HW") }}" == "UNDEF_HW"'
|
||||
- '"{{ ansible_virtualization_role|default("UNDEF_VIRT") }}" != "UNDEF_VIRT"'
|
||||
|
||||
- hosts: facthost7
|
||||
tags: [ 'fact_negation' ]
|
||||
connection: local
|
||||
gather_subset: "!hardware"
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Test that negation of fact subsets work
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_user_id|default("UNDEF_MIN") }}" != "UNDEF_MIN"'
|
||||
- '"{{ ansible_interfaces|default("UNDEF_NET") }}" != "UNDEF_NET"'
|
||||
- '"{{ ansible_mounts|default("UNDEF_HW") }}" == "UNDEF_HW"'
|
||||
- '"{{ ansible_virtualization_role|default("UNDEF_VIRT") }}" != "UNDEF_VIRT"'
|
||||
|
||||
- hosts: facthost8
|
||||
tags: [ 'fact_mixed_negation_addition' ]
|
||||
connection: local
|
||||
gather_subset: "!hardware,network"
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Test that negation and additional subsets work together
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_user_id|default("UNDEF_MIN") }}" != "UNDEF_MIN"'
|
||||
- '"{{ ansible_interfaces|default("UNDEF_NET") }}" != "UNDEF_NET"'
|
||||
- '"{{ ansible_mounts|default("UNDEF_HW") }}" == "UNDEF_HW"'
|
||||
- '"{{ ansible_virtualization_role|default("UNDEF_VIRT") }}" == "UNDEF_VIRT"'
|
||||
|
@ -0,0 +1,26 @@
|
||||
- hosts: testhost
|
||||
gather_facts: no
|
||||
tags:
|
||||
- always
|
||||
tasks:
|
||||
- name: ensure fail action produces a failing result
|
||||
fail:
|
||||
ignore_errors: yes
|
||||
register: fail_out
|
||||
|
||||
- debug:
|
||||
msg: fail works ({{ fail_out.failed }})
|
||||
|
||||
- name: ensure assert produces a failing result
|
||||
assert:
|
||||
that: false
|
||||
ignore_errors: yes
|
||||
register: assert_out
|
||||
|
||||
- debug:
|
||||
msg: assert works ({{ assert_out.failed }})
|
||||
|
||||
- name: ensure fail action stops execution
|
||||
fail:
|
||||
msg: fail actually failed (this is expected)
|
||||
|
@ -0,0 +1,130 @@
|
||||
# (c) 2016, James Cammarata <jimi@sngx.net>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests import unittest
|
||||
from ansible.compat.tests.mock import patch, MagicMock
|
||||
|
||||
from ansible.executor.task_result import TaskResult
|
||||
|
||||
class TestTaskResult(unittest.TestCase):
|
||||
def test_task_result_basic(self):
|
||||
mock_host = MagicMock()
|
||||
mock_task = MagicMock()
|
||||
|
||||
# test loading a result with a dict
|
||||
tr = TaskResult(mock_host, mock_task, dict())
|
||||
|
||||
# test loading a result with a JSON string
|
||||
with patch('ansible.parsing.dataloader.DataLoader.load') as p:
|
||||
tr = TaskResult(mock_host, mock_task, '{}')
|
||||
|
||||
def test_task_result_is_changed(self):
|
||||
mock_host = MagicMock()
|
||||
mock_task = MagicMock()
|
||||
|
||||
# test with no changed in result
|
||||
tr = TaskResult(mock_host, mock_task, dict())
|
||||
self.assertFalse(tr.is_changed())
|
||||
|
||||
# test with changed in the result
|
||||
tr = TaskResult(mock_host, mock_task, dict(changed=True))
|
||||
self.assertTrue(tr.is_changed())
|
||||
|
||||
# test with multiple results but none changed
|
||||
mock_task.loop = 'foo'
|
||||
tr = TaskResult(mock_host, mock_task, dict(results=[dict(foo='bar'), dict(bam='baz'), True]))
|
||||
self.assertFalse(tr.is_changed())
|
||||
|
||||
# test with multiple results and one changed
|
||||
mock_task.loop = 'foo'
|
||||
tr = TaskResult(mock_host, mock_task, dict(results=[dict(changed=False), dict(changed=True), dict(some_key=False)]))
|
||||
self.assertTrue(tr.is_changed())
|
||||
|
||||
def test_task_result_is_skipped(self):
|
||||
mock_host = MagicMock()
|
||||
mock_task = MagicMock()
|
||||
|
||||
# test with no skipped in result
|
||||
tr = TaskResult(mock_host, mock_task, dict())
|
||||
self.assertFalse(tr.is_skipped())
|
||||
|
||||
# test with skipped in the result
|
||||
tr = TaskResult(mock_host, mock_task, dict(skipped=True))
|
||||
self.assertTrue(tr.is_skipped())
|
||||
|
||||
# test with multiple results but none skipped
|
||||
mock_task.loop = 'foo'
|
||||
tr = TaskResult(mock_host, mock_task, dict(results=[dict(foo='bar'), dict(bam='baz'), True]))
|
||||
self.assertFalse(tr.is_skipped())
|
||||
|
||||
# test with multiple results and one skipped
|
||||
mock_task.loop = 'foo'
|
||||
tr = TaskResult(mock_host, mock_task, dict(results=[dict(skipped=False), dict(skipped=True), dict(some_key=False)]))
|
||||
self.assertFalse(tr.is_skipped())
|
||||
|
||||
# test with multiple results and all skipped
|
||||
mock_task.loop = 'foo'
|
||||
tr = TaskResult(mock_host, mock_task, dict(results=[dict(skipped=True), dict(skipped=True), dict(skipped=True)]))
|
||||
self.assertTrue(tr.is_skipped())
|
||||
|
||||
def test_task_result_is_unreachable(self):
|
||||
mock_host = MagicMock()
|
||||
mock_task = MagicMock()
|
||||
|
||||
# test with no unreachable in result
|
||||
tr = TaskResult(mock_host, mock_task, dict())
|
||||
self.assertFalse(tr.is_unreachable())
|
||||
|
||||
# test with unreachable in the result
|
||||
tr = TaskResult(mock_host, mock_task, dict(unreachable=True))
|
||||
self.assertTrue(tr.is_unreachable())
|
||||
|
||||
# test with multiple results but none unreachable
|
||||
mock_task.loop = 'foo'
|
||||
tr = TaskResult(mock_host, mock_task, dict(results=[dict(foo='bar'), dict(bam='baz'), True]))
|
||||
self.assertFalse(tr.is_unreachable())
|
||||
|
||||
# test with multiple results and one unreachable
|
||||
mock_task.loop = 'foo'
|
||||
tr = TaskResult(mock_host, mock_task, dict(results=[dict(unreachable=False), dict(unreachable=True), dict(some_key=False)]))
|
||||
self.assertTrue(tr.is_unreachable())
|
||||
|
||||
def test_task_result_is_failed(self):
|
||||
mock_host = MagicMock()
|
||||
mock_task = MagicMock()
|
||||
|
||||
# test with no failed in result
|
||||
tr = TaskResult(mock_host, mock_task, dict())
|
||||
self.assertFalse(tr.is_failed())
|
||||
|
||||
# test failed result with rc values
|
||||
tr = TaskResult(mock_host, mock_task, dict(rc=0))
|
||||
self.assertFalse(tr.is_failed())
|
||||
tr = TaskResult(mock_host, mock_task, dict(rc=1))
|
||||
self.assertTrue(tr.is_failed())
|
||||
|
||||
# test with failed in result
|
||||
tr = TaskResult(mock_host, mock_task, dict(failed=True))
|
||||
self.assertTrue(tr.is_failed())
|
||||
|
||||
# test with failed_when in result
|
||||
tr = TaskResult(mock_host, mock_task, dict(failed_when_result=True))
|
||||
self.assertTrue(tr.is_failed())
|
@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2016, James Cammarata <jimi@sngx.net>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
from ansible.compat.tests import unittest
|
||||
from ansible.compat.tests.mock import MagicMock
|
||||
|
||||
class TestModuleUtilsBasic(unittest.TestCase):
|
||||
|
||||
def test_module_utils_basic__log_invocation(self):
|
||||
from ansible.module_utils import basic
|
||||
|
||||
# test basic log invocation
|
||||
basic.MODULE_COMPLEX_ARGS = json.dumps(dict(foo=False, bar=[1,2,3], bam="bam", baz=u'baz'))
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec=dict(
|
||||
foo = dict(default=True, type='bool'),
|
||||
bar = dict(default=[], type='list'),
|
||||
bam = dict(default="bam"),
|
||||
baz = dict(default=u"baz"),
|
||||
password = dict(default=True),
|
||||
no_log = dict(default="you shouldn't see me", no_log=True),
|
||||
),
|
||||
)
|
||||
|
||||
am.log = MagicMock()
|
||||
am._log_invocation()
|
||||
am.log.assert_called_with(
|
||||
'Invoked with bam=bam bar=[1, 2, 3] foo=False baz=baz no_log=NOT_LOGGING_PARAMETER password=NOT_LOGGING_PASSWORD ',
|
||||
log_args={
|
||||
'foo': 'False',
|
||||
'bar': '[1, 2, 3]',
|
||||
'bam': 'bam',
|
||||
'baz': 'baz',
|
||||
'password': 'NOT_LOGGING_PASSWORD',
|
||||
'no_log': 'NOT_LOGGING_PARAMETER',
|
||||
},
|
||||
)
|
@ -0,0 +1,64 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2015, Toshio Kuratomi <tkuratomi@ansible.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests import unittest
|
||||
|
||||
|
||||
class TestAnsibleModuleExitJson(unittest.TestCase):
|
||||
|
||||
def test_module_utils_basic_safe_eval(self):
|
||||
from ansible.module_utils import basic
|
||||
|
||||
basic.MODULE_COMPLEX_ARGS = '{}'
|
||||
am = basic.AnsibleModule(
|
||||
argument_spec=dict(),
|
||||
)
|
||||
|
||||
# test some basic usage
|
||||
# string (and with exceptions included), integer, bool
|
||||
self.assertEqual(am.safe_eval("'a'"), 'a')
|
||||
self.assertEqual(am.safe_eval("'a'", include_exceptions=True), ('a', None))
|
||||
self.assertEqual(am.safe_eval("1"), 1)
|
||||
self.assertEqual(am.safe_eval("True"), True)
|
||||
self.assertEqual(am.safe_eval("False"), False)
|
||||
self.assertEqual(am.safe_eval("{}"), {})
|
||||
# not passing in a string to convert
|
||||
self.assertEqual(am.safe_eval({'a':1}), {'a':1})
|
||||
self.assertEqual(am.safe_eval({'a':1}, include_exceptions=True), ({'a':1}, None))
|
||||
# invalid literal eval
|
||||
self.assertEqual(am.safe_eval("a=1"), "a=1")
|
||||
res = am.safe_eval("a=1", include_exceptions=True)
|
||||
self.assertEqual(res[0], "a=1")
|
||||
self.assertEqual(type(res[1]), SyntaxError)
|
||||
self.assertEqual(am.safe_eval("a.foo()"), "a.foo()")
|
||||
res = am.safe_eval("a.foo()", include_exceptions=True)
|
||||
self.assertEqual(res[0], "a.foo()")
|
||||
self.assertEqual(res[1], None)
|
||||
self.assertEqual(am.safe_eval("import foo"), "import foo")
|
||||
res = am.safe_eval("import foo", include_exceptions=True)
|
||||
self.assertEqual(res[0], "import foo")
|
||||
self.assertEqual(res[1], None)
|
||||
self.assertEqual(am.safe_eval("__import__('foo')"), "__import__('foo')")
|
||||
res = am.safe_eval("__import__('foo')", include_exceptions=True)
|
||||
self.assertEqual(res[0], "__import__('foo')")
|
||||
self.assertEqual(type(res[1]), ValueError)
|
||||
|
@ -0,0 +1,82 @@
|
||||
# (c) 2012-2014, Chris Meyers <chris.meyers.fsu@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from six import PY3
|
||||
from copy import deepcopy
|
||||
|
||||
from ansible.compat.tests import unittest
|
||||
from ansible.compat.tests.mock import patch, mock_open
|
||||
|
||||
from ansible.plugins.callback import CallbackBase
|
||||
import ansible.plugins.callback as callish
|
||||
|
||||
class TestCopyResultExclude(unittest.TestCase):
|
||||
def setUp(self):
|
||||
class DummyClass():
|
||||
def __init__(self):
|
||||
self.bar = [ 1, 2, 3 ]
|
||||
self.a = {
|
||||
"b": 2,
|
||||
"c": 3,
|
||||
}
|
||||
self.b = {
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
}
|
||||
self.foo = DummyClass()
|
||||
self.cb = CallbackBase()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_copy_logic(self):
|
||||
res = self.cb._copy_result_exclude(self.foo, ())
|
||||
self.assertEqual(self.foo.bar, res.bar)
|
||||
|
||||
def test_copy_deep(self):
|
||||
res = self.cb._copy_result_exclude(self.foo, ())
|
||||
self.assertNotEqual(id(self.foo.bar), id(res.bar))
|
||||
|
||||
def test_no_exclude(self):
|
||||
res = self.cb._copy_result_exclude(self.foo, ())
|
||||
self.assertEqual(self.foo.bar, res.bar)
|
||||
self.assertEqual(self.foo.a, res.a)
|
||||
self.assertEqual(self.foo.b, res.b)
|
||||
|
||||
def test_exclude(self):
|
||||
res = self.cb._copy_result_exclude(self.foo, ['bar', 'b'])
|
||||
self.assertIsNone(res.bar)
|
||||
self.assertIsNone(res.b)
|
||||
self.assertEqual(self.foo.a, res.a)
|
||||
|
||||
def test_result_unmodified(self):
|
||||
bar_id = id(self.foo.bar)
|
||||
a_id = id(self.foo.a)
|
||||
res = self.cb._copy_result_exclude(self.foo, ['bar', 'a'])
|
||||
|
||||
self.assertEqual(self.foo.bar, [ 1, 2, 3 ])
|
||||
self.assertEqual(bar_id, id(self.foo.bar))
|
||||
|
||||
self.assertEqual(self.foo.a, dict(b=2, c=3))
|
||||
self.assertEqual(a_id, id(self.foo.a))
|
||||
|
||||
self.assertRaises(AttributeError, self.cb._copy_result_exclude, self.foo, ['a', 'c', 'bar'])
|
||||
|
@ -0,0 +1,368 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2015, Toshio Kuratomi <tkuratomi@ansible.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import pipes
|
||||
import sys
|
||||
from io import StringIO
|
||||
|
||||
from ansible.compat.tests import unittest
|
||||
from ansible.compat.tests.mock import patch, MagicMock, mock_open
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
||||
from ansible.playbook.play_context import PlayContext
|
||||
from ansible.plugins.connection import ssh
|
||||
from ansible.utils.unicode import to_bytes, to_unicode
|
||||
|
||||
class TestConnectionBaseClass(unittest.TestCase):
|
||||
|
||||
def test_plugins_connection_ssh_basic(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = ssh.Connection(pc, new_stdin)
|
||||
|
||||
# connect just returns self, so assert that
|
||||
res = conn._connect()
|
||||
self.assertEqual(conn, res)
|
||||
|
||||
ssh.SSHPASS_AVAILABLE = False
|
||||
self.assertFalse(conn._sshpass_available())
|
||||
|
||||
ssh.SSHPASS_AVAILABLE = True
|
||||
self.assertTrue(conn._sshpass_available())
|
||||
|
||||
with patch('subprocess.Popen') as p:
|
||||
ssh.SSHPASS_AVAILABLE = None
|
||||
p.return_value = MagicMock()
|
||||
self.assertTrue(conn._sshpass_available())
|
||||
|
||||
ssh.SSHPASS_AVAILABLE = None
|
||||
p.return_value = None
|
||||
p.side_effect = OSError()
|
||||
self.assertFalse(conn._sshpass_available())
|
||||
|
||||
conn.close()
|
||||
self.assertFalse(conn._connected)
|
||||
|
||||
def test_plugins_connection_ssh__build_command(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = ssh.Connection(pc, new_stdin)
|
||||
conn._build_command('ssh')
|
||||
|
||||
def test_plugins_connection_ssh__exec_command(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = ssh.Connection(pc, new_stdin)
|
||||
|
||||
conn._build_command = MagicMock()
|
||||
conn._build_command.return_value = 'ssh something something'
|
||||
conn._run = MagicMock()
|
||||
conn._run.return_value = (0, 'stdout', 'stderr')
|
||||
|
||||
res, stdout, stderr = conn._exec_command('ssh')
|
||||
res, stdout, stderr = conn._exec_command('ssh', 'this is some data')
|
||||
|
||||
@patch('select.select')
|
||||
@patch('fcntl.fcntl')
|
||||
@patch('os.write')
|
||||
@patch('os.close')
|
||||
@patch('pty.openpty')
|
||||
@patch('subprocess.Popen')
|
||||
def test_plugins_connection_ssh__run(self, mock_Popen, mock_openpty, mock_osclose, mock_oswrite, mock_fcntl, mock_select):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
|
||||
conn = ssh.Connection(pc, new_stdin)
|
||||
conn._send_initial_data = MagicMock()
|
||||
conn._examine_output = MagicMock()
|
||||
conn._terminate_process = MagicMock()
|
||||
conn.sshpass_pipe = [MagicMock(), MagicMock()]
|
||||
|
||||
mock_popen_res = MagicMock()
|
||||
mock_popen_res.poll = MagicMock()
|
||||
mock_popen_res.wait = MagicMock()
|
||||
mock_popen_res.stdin = MagicMock()
|
||||
mock_popen_res.stdin.fileno.return_value = 1000
|
||||
mock_popen_res.stdout = MagicMock()
|
||||
mock_popen_res.stdout.fileno.return_value = 1001
|
||||
mock_popen_res.stderr = MagicMock()
|
||||
mock_popen_res.stderr.fileno.return_value = 1002
|
||||
mock_popen_res.return_code = 0
|
||||
mock_Popen.return_value = mock_popen_res
|
||||
|
||||
def _mock_select(rlist, wlist, elist, timeout=None):
|
||||
rvals = []
|
||||
if mock_popen_res.stdin in rlist:
|
||||
rvals.append(mock_popen_res.stdin)
|
||||
if mock_popen_res.stderr in rlist:
|
||||
rvals.append(mock_popen_res.stderr)
|
||||
return (rvals, [], [])
|
||||
|
||||
mock_select.side_effect = _mock_select
|
||||
|
||||
mock_popen_res.stdout.read.side_effect = ["some data", ""]
|
||||
mock_popen_res.stderr.read.side_effect = [""]
|
||||
conn._run("ssh", "this is input data")
|
||||
|
||||
# test with a password set to trigger the sshpass write
|
||||
pc.password = '12345'
|
||||
mock_popen_res.stdout.read.side_effect = ["some data", "", ""]
|
||||
mock_popen_res.stderr.read.side_effect = [""]
|
||||
conn._run(["ssh", "is", "a", "cmd"], "this is more data")
|
||||
|
||||
# test with password prompting enabled
|
||||
pc.password = None
|
||||
pc.prompt = True
|
||||
mock_popen_res.stdout.read.side_effect = ["some data", "", ""]
|
||||
mock_popen_res.stderr.read.side_effect = [""]
|
||||
conn._run("ssh", "this is input data")
|
||||
|
||||
# test with some become settings
|
||||
pc.prompt = False
|
||||
pc.become = True
|
||||
pc.success_key = 'BECOME-SUCCESS-abcdefg'
|
||||
mock_popen_res.stdout.read.side_effect = ["some data", "", ""]
|
||||
mock_popen_res.stderr.read.side_effect = [""]
|
||||
conn._run("ssh", "this is input data")
|
||||
|
||||
# simulate no data input
|
||||
mock_openpty.return_value = (98, 99)
|
||||
mock_popen_res.stdout.read.side_effect = ["some data", "", ""]
|
||||
mock_popen_res.stderr.read.side_effect = [""]
|
||||
conn._run("ssh", "")
|
||||
|
||||
# simulate no data input but Popen using new pty's fails
|
||||
mock_Popen.return_value = None
|
||||
mock_Popen.side_effect = [OSError(), mock_popen_res]
|
||||
mock_popen_res.stdout.read.side_effect = ["some data", "", ""]
|
||||
mock_popen_res.stderr.read.side_effect = [""]
|
||||
conn._run("ssh", "")
|
||||
|
||||
def test_plugins_connection_ssh__examine_output(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
|
||||
conn = ssh.Connection(pc, new_stdin)
|
||||
|
||||
conn.check_password_prompt = MagicMock()
|
||||
conn.check_become_success = MagicMock()
|
||||
conn.check_incorrect_password = MagicMock()
|
||||
conn.check_missing_password = MagicMock()
|
||||
|
||||
def _check_password_prompt(line):
|
||||
if 'foo' in line:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _check_become_success(line):
|
||||
if 'BECOME-SUCCESS-abcdefghijklmnopqrstuvxyz' in line:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _check_incorrect_password(line):
|
||||
if 'incorrect password' in line:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _check_missing_password(line):
|
||||
if 'bad password' in line:
|
||||
return True
|
||||
return False
|
||||
|
||||
conn.check_password_prompt.side_effect = _check_password_prompt
|
||||
conn.check_become_success.side_effect = _check_become_success
|
||||
conn.check_incorrect_password.side_effect = _check_incorrect_password
|
||||
conn.check_missing_password.side_effect = _check_missing_password
|
||||
|
||||
# test examining output for prompt
|
||||
conn._flags = dict(
|
||||
become_prompt = False,
|
||||
become_success = False,
|
||||
become_error = False,
|
||||
become_nopasswd_error = False,
|
||||
)
|
||||
|
||||
pc.prompt = True
|
||||
output, unprocessed = conn._examine_output('source', 'state', 'line 1\nline 2\nfoo\nline 3\nthis should be the remainder', False)
|
||||
self.assertEqual(output, 'line 1\nline 2\nline 3\n')
|
||||
self.assertEqual(unprocessed, 'this should be the remainder')
|
||||
self.assertTrue(conn._flags['become_prompt'])
|
||||
self.assertFalse(conn._flags['become_success'])
|
||||
self.assertFalse(conn._flags['become_error'])
|
||||
self.assertFalse(conn._flags['become_nopasswd_error'])
|
||||
|
||||
# test examining output for become prompt
|
||||
conn._flags = dict(
|
||||
become_prompt = False,
|
||||
become_success = False,
|
||||
become_error = False,
|
||||
become_nopasswd_error = False,
|
||||
)
|
||||
|
||||
pc.prompt = False
|
||||
pc.success_key = 'BECOME-SUCCESS-abcdefghijklmnopqrstuvxyz'
|
||||
output, unprocessed = conn._examine_output('source', 'state', 'line 1\nline 2\nBECOME-SUCCESS-abcdefghijklmnopqrstuvxyz\nline 3\n', False)
|
||||
self.assertEqual(output, 'line 1\nline 2\nline 3\n')
|
||||
self.assertEqual(unprocessed, '')
|
||||
self.assertFalse(conn._flags['become_prompt'])
|
||||
self.assertTrue(conn._flags['become_success'])
|
||||
self.assertFalse(conn._flags['become_error'])
|
||||
self.assertFalse(conn._flags['become_nopasswd_error'])
|
||||
|
||||
# test examining output for become failure
|
||||
conn._flags = dict(
|
||||
become_prompt = False,
|
||||
become_success = False,
|
||||
become_error = False,
|
||||
become_nopasswd_error = False,
|
||||
)
|
||||
|
||||
pc.prompt = False
|
||||
pc.success_key = None
|
||||
output, unprocessed = conn._examine_output('source', 'state', 'line 1\nline 2\nincorrect password\n', True)
|
||||
self.assertEqual(output, 'line 1\nline 2\nincorrect password\n')
|
||||
self.assertEqual(unprocessed, '')
|
||||
self.assertFalse(conn._flags['become_prompt'])
|
||||
self.assertFalse(conn._flags['become_success'])
|
||||
self.assertTrue(conn._flags['become_error'])
|
||||
self.assertFalse(conn._flags['become_nopasswd_error'])
|
||||
|
||||
# test examining output for missing password
|
||||
conn._flags = dict(
|
||||
become_prompt = False,
|
||||
become_success = False,
|
||||
become_error = False,
|
||||
become_nopasswd_error = False,
|
||||
)
|
||||
|
||||
pc.prompt = False
|
||||
pc.success_key = None
|
||||
output, unprocessed = conn._examine_output('source', 'state', 'line 1\nbad password\n', True)
|
||||
self.assertEqual(output, 'line 1\nbad password\n')
|
||||
self.assertEqual(unprocessed, '')
|
||||
self.assertFalse(conn._flags['become_prompt'])
|
||||
self.assertFalse(conn._flags['become_success'])
|
||||
self.assertFalse(conn._flags['become_error'])
|
||||
self.assertTrue(conn._flags['become_nopasswd_error'])
|
||||
|
||||
@patch('time.sleep')
|
||||
def test_plugins_connection_ssh_exec_command(self, mock_sleep):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = ssh.Connection(pc, new_stdin)
|
||||
conn._build_command = MagicMock()
|
||||
conn._exec_command = MagicMock()
|
||||
|
||||
C.ANSIBLE_SSH_RETRIES = 9
|
||||
|
||||
# test a regular, successful execution
|
||||
conn._exec_command.return_value = (0, 'stdout', '')
|
||||
res = conn.exec_command('ssh', 'some data')
|
||||
|
||||
# test a retry, followed by success
|
||||
conn._exec_command.return_value = None
|
||||
conn._exec_command.side_effect = [(255, '', ''), (0, 'stdout', '')]
|
||||
res = conn.exec_command('ssh', 'some data')
|
||||
|
||||
# test multiple failures
|
||||
conn._exec_command.side_effect = [(255, '', '')]*10
|
||||
self.assertRaises(AnsibleConnectionFailure, conn.exec_command, 'ssh', 'some data')
|
||||
|
||||
# test other failure from exec_command
|
||||
conn._exec_command.side_effect = [Exception('bad')]*10
|
||||
self.assertRaises(Exception, conn.exec_command, 'ssh', 'some data')
|
||||
|
||||
@patch('os.path.exists')
|
||||
def test_plugins_connection_ssh_put_file(self, mock_ospe):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = ssh.Connection(pc, new_stdin)
|
||||
conn._build_command = MagicMock()
|
||||
conn._run = MagicMock()
|
||||
|
||||
mock_ospe.return_value = True
|
||||
conn._build_command.return_value = 'some command to run'
|
||||
conn._run.return_value = (0, '', '')
|
||||
conn.host = "some_host"
|
||||
|
||||
# test with C.DEFAULT_SCP_IF_SSH enabled
|
||||
C.DEFAULT_SCP_IF_SSH = True
|
||||
res = conn.put_file('/path/to/in/file', '/path/to/dest/file')
|
||||
conn._run.assert_called_with('some command to run', None)
|
||||
|
||||
res = conn.put_file(u'/path/to/in/file/with/unicode-fö〩', u'/path/to/dest/file/with/unicode-fö〩')
|
||||
conn._run.assert_called_with('some command to run', None)
|
||||
|
||||
# test with C.DEFAULT_SCP_IF_SSH disabled
|
||||
C.DEFAULT_SCP_IF_SSH = False
|
||||
expected_in_data = b' '.join((b'put', to_bytes(pipes.quote('/path/to/in/file')), to_bytes(pipes.quote('/path/to/dest/file')))) + b'\n'
|
||||
res = conn.put_file('/path/to/in/file', '/path/to/dest/file')
|
||||
conn._run.assert_called_with('some command to run', expected_in_data)
|
||||
|
||||
expected_in_data = b' '.join((b'put', to_bytes(pipes.quote('/path/to/in/file/with/unicode-fö〩')), to_bytes(pipes.quote('/path/to/dest/file/with/unicode-fö〩')))) + b'\n'
|
||||
res = conn.put_file(u'/path/to/in/file/with/unicode-fö〩', u'/path/to/dest/file/with/unicode-fö〩')
|
||||
conn._run.assert_called_with('some command to run', expected_in_data)
|
||||
|
||||
# test that a non-zero rc raises an error
|
||||
conn._run.return_value = (1, 'stdout', 'some errors')
|
||||
self.assertRaises(AnsibleError, conn.put_file, '/path/to/bad/file', '/remote/path/to/file')
|
||||
|
||||
# test that a not-found path raises an error
|
||||
mock_ospe.return_value = False
|
||||
conn._run.return_value = (0, 'stdout', '')
|
||||
self.assertRaises(AnsibleFileNotFound, conn.put_file, '/path/to/bad/file', '/remote/path/to/file')
|
||||
|
||||
def test_plugins_connection_ssh_fetch_file(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = ssh.Connection(pc, new_stdin)
|
||||
conn._build_command = MagicMock()
|
||||
conn._run = MagicMock()
|
||||
|
||||
conn._build_command.return_value = 'some command to run'
|
||||
conn._run.return_value = (0, '', '')
|
||||
conn.host = "some_host"
|
||||
|
||||
# test with C.DEFAULT_SCP_IF_SSH enabled
|
||||
C.DEFAULT_SCP_IF_SSH = True
|
||||
res = conn.fetch_file('/path/to/in/file', '/path/to/dest/file')
|
||||
conn._run.assert_called_with('some command to run', None)
|
||||
|
||||
res = conn.fetch_file(u'/path/to/in/file/with/unicode-fö〩', u'/path/to/dest/file/with/unicode-fö〩')
|
||||
conn._run.assert_called_with('some command to run', None)
|
||||
|
||||
# test with C.DEFAULT_SCP_IF_SSH disabled
|
||||
C.DEFAULT_SCP_IF_SSH = False
|
||||
expected_in_data = b' '.join((b'get', to_bytes(pipes.quote('/path/to/in/file')), to_bytes(pipes.quote('/path/to/dest/file')))) + b'\n'
|
||||
res = conn.fetch_file('/path/to/in/file', '/path/to/dest/file')
|
||||
conn._run.assert_called_with('some command to run', expected_in_data)
|
||||
|
||||
expected_in_data = b' '.join((b'get', to_bytes(pipes.quote('/path/to/in/file/with/unicode-fö〩')), to_bytes(pipes.quote('/path/to/dest/file/with/unicode-fö〩')))) + b'\n'
|
||||
res = conn.fetch_file(u'/path/to/in/file/with/unicode-fö〩', u'/path/to/dest/file/with/unicode-fö〩')
|
||||
conn._run.assert_called_with('some command to run', expected_in_data)
|
||||
|
||||
# test that a non-zero rc raises an error
|
||||
conn._run.return_value = (1, 'stdout', 'some errors')
|
||||
self.assertRaises(AnsibleError, conn.fetch_file, '/path/to/bad/file', '/remote/path/to/file')
|
||||
|
@ -0,0 +1,45 @@
|
||||
# Latest version of centos
|
||||
FROM centos:centos6
|
||||
RUN yum -y update; yum clean all;
|
||||
RUN yum -y install \
|
||||
epel-release \
|
||||
file \
|
||||
gcc \
|
||||
git \
|
||||
make \
|
||||
mercurial \
|
||||
rubygems \
|
||||
sed \
|
||||
subversion \
|
||||
sudo \
|
||||
unzip \
|
||||
openssh-clients \
|
||||
openssh-server \
|
||||
which
|
||||
RUN yum -y install \
|
||||
PyYAML \
|
||||
python-coverage \
|
||||
python-devel \
|
||||
python-httplib2 \
|
||||
python-jinja2 \
|
||||
python-keyczar \
|
||||
python-mock \
|
||||
python-nose \
|
||||
python-paramiko \
|
||||
python-pip \
|
||||
python-setuptools \
|
||||
python-virtualenv
|
||||
RUN pip install --upgrade jinja2
|
||||
RUN rpm -e --nodeps python-crypto; pip install pycrypto
|
||||
RUN /bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
RUN mkdir /etc/ansible/
|
||||
RUN /bin/echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
|
||||
#VOLUME /sys/fs/cgroup /run /tmp
|
||||
RUN ssh-keygen -q -t rsa1 -N '' -f /etc/ssh/ssh_host_key && \
|
||||
ssh-keygen -q -t dsa -N '' -f /etc/ssh/ssh_host_dsa_key && \
|
||||
ssh-keygen -q -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key && \
|
||||
ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa && \
|
||||
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
|
||||
for key in /etc/ssh/ssh_host_*_key.pub; do echo "localhost $(cat ${key})" >> /root/.ssh/known_hosts; done
|
||||
ENV container=docker
|
||||
CMD ["/sbin/init"]
|
@ -0,0 +1,50 @@
|
||||
# Latest version of centos
|
||||
FROM centos:centos7
|
||||
RUN yum -y update; yum clean all; yum -y swap fakesystemd systemd
|
||||
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
|
||||
rm -f /lib/systemd/system/multi-user.target.wants/*; \
|
||||
rm -f /etc/systemd/system/*.wants/*; \
|
||||
rm -f /lib/systemd/system/local-fs.target.wants/*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
|
||||
rm -f /lib/systemd/system/basic.target.wants/*; \
|
||||
rm -f /lib/systemd/system/anaconda.target.wants/*;
|
||||
RUN yum -y install \
|
||||
dbus-python \
|
||||
epel-release \
|
||||
file \
|
||||
git \
|
||||
iproute \
|
||||
make \
|
||||
mercurial \
|
||||
rubygems \
|
||||
subversion \
|
||||
sudo \
|
||||
unzip \
|
||||
openssh-clients \
|
||||
openssh-server \
|
||||
which
|
||||
RUN yum -y install \
|
||||
PyYAML \
|
||||
python-coverage \
|
||||
python-httplib2 \
|
||||
python-jinja2 \
|
||||
python-keyczar \
|
||||
python-mock \
|
||||
python-nose \
|
||||
python-paramiko \
|
||||
python-pip \
|
||||
python-setuptools \
|
||||
python-virtualenv
|
||||
RUN /usr/bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
RUN mkdir /etc/ansible/
|
||||
RUN /usr/bin/echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
|
||||
VOLUME /sys/fs/cgroup /run /tmp
|
||||
RUN ssh-keygen -q -t rsa1 -N '' -f /etc/ssh/ssh_host_key && \
|
||||
ssh-keygen -q -t dsa -N '' -f /etc/ssh/ssh_host_dsa_key && \
|
||||
ssh-keygen -q -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key && \
|
||||
ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa && \
|
||||
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
|
||||
for key in /etc/ssh/ssh_host_*_key.pub; do echo "localhost $(cat ${key})" >> /root/.ssh/known_hosts; done
|
||||
ENV container=docker
|
||||
CMD ["/usr/sbin/init"]
|
@ -0,0 +1,54 @@
|
||||
# Latest version of fedora rawhide
|
||||
FROM fedora:rawhide
|
||||
RUN dnf -y update; dnf clean all
|
||||
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
|
||||
rm -f /lib/systemd/system/multi-user.target.wants/*; \
|
||||
rm -f /etc/systemd/system/*.wants/*; \
|
||||
rm -f /lib/systemd/system/local-fs.target.wants/*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
|
||||
rm -f /lib/systemd/system/basic.target.wants/*; \
|
||||
rm -f /lib/systemd/system/anaconda.target.wants/*;
|
||||
RUN dnf -y install \
|
||||
dbus-python \
|
||||
file \
|
||||
findutils \
|
||||
git \
|
||||
glibc-locale-source \
|
||||
iproute \
|
||||
make \
|
||||
mercurial \
|
||||
procps \
|
||||
PyYAML \
|
||||
python-coverage \
|
||||
python2-dnf \
|
||||
python-httplib2 \
|
||||
python-jinja2 \
|
||||
python-keyczar \
|
||||
python-mock \
|
||||
python-nose \
|
||||
python-paramiko \
|
||||
python-pip \
|
||||
python-setuptools \
|
||||
python-virtualenv \
|
||||
rubygems \
|
||||
subversion \
|
||||
sudo \
|
||||
tar \
|
||||
unzip \
|
||||
which \
|
||||
openssh-clients \
|
||||
openssh-server \
|
||||
yum
|
||||
RUN localedef --quiet -c -i en_US -f UTF-8 en_US.UTF-8
|
||||
RUN /usr/bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
RUN mkdir /etc/ansible/
|
||||
RUN /usr/bin/echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
|
||||
VOLUME /sys/fs/cgroup /run /tmp
|
||||
RUN ssh-keygen -q -t dsa -N '' -f /etc/ssh/ssh_host_dsa_key && \
|
||||
ssh-keygen -q -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key && \
|
||||
ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa && \
|
||||
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
|
||||
for key in /etc/ssh/ssh_host_*_key.pub; do echo "localhost $(cat ${key})" >> /root/.ssh/known_hosts; done
|
||||
ENV container=docker
|
||||
CMD ["/usr/sbin/init"]
|
@ -0,0 +1,55 @@
|
||||
# Latest version of centos
|
||||
FROM fedora:23
|
||||
RUN dnf -y update; dnf clean all
|
||||
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
|
||||
rm -f /lib/systemd/system/multi-user.target.wants/*; \
|
||||
rm -f /etc/systemd/system/*.wants/*; \
|
||||
rm -f /lib/systemd/system/local-fs.target.wants/*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
|
||||
rm -f /lib/systemd/system/basic.target.wants/*; \
|
||||
rm -f /lib/systemd/system/anaconda.target.wants/*;
|
||||
RUN dnf -y install \
|
||||
dbus-python \
|
||||
file \
|
||||
findutils \
|
||||
glibc-common \
|
||||
git \
|
||||
iproute \
|
||||
make \
|
||||
mercurial \
|
||||
procps \
|
||||
PyYAML \
|
||||
python-coverage \
|
||||
python2-dnf \
|
||||
python-httplib2 \
|
||||
python-jinja2 \
|
||||
python-keyczar \
|
||||
python-mock \
|
||||
python-nose \
|
||||
python-paramiko \
|
||||
python-pip \
|
||||
python-setuptools \
|
||||
python-virtualenv \
|
||||
rubygems \
|
||||
subversion \
|
||||
sudo \
|
||||
tar \
|
||||
unzip \
|
||||
which \
|
||||
openssh-clients \
|
||||
openssh-server \
|
||||
yum
|
||||
RUN localedef --quiet -f ISO-8859-1 -i pt_BR pt_BR
|
||||
RUN localedef --quiet -f ISO-8859-1 -i es_MX es_MX
|
||||
RUN /usr/bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
RUN mkdir /etc/ansible/
|
||||
RUN /usr/bin/echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
|
||||
VOLUME /sys/fs/cgroup /run /tmp
|
||||
RUN ssh-keygen -q -t dsa -N '' -f /etc/ssh/ssh_host_dsa_key && \
|
||||
ssh-keygen -q -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key && \
|
||||
ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa && \
|
||||
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
|
||||
for key in /etc/ssh/ssh_host_*_key.pub; do echo "localhost $(cat ${key})" >> /root/.ssh/known_hosts; done
|
||||
ENV container=docker
|
||||
CMD ["/usr/sbin/init"]
|
@ -0,0 +1,69 @@
|
||||
FROM ubuntu:precise
|
||||
RUN apt-get clean; apt-get update -y;
|
||||
RUN apt-get install -y \
|
||||
debianutils \
|
||||
gawk \
|
||||
git \
|
||||
locales \
|
||||
make \
|
||||
mercurial \
|
||||
ruby \
|
||||
rubygems \
|
||||
subversion \
|
||||
sudo \
|
||||
openssh-client \
|
||||
openssh-server \
|
||||
unzip
|
||||
|
||||
# helpful things taken from the ubuntu-upstart Dockerfile:
|
||||
# https://github.com/tianon/dockerfiles/blob/4d24a12b54b75b3e0904d8a285900d88d3326361/sbin-init/ubuntu/upstart/14.04/Dockerfile
|
||||
ADD init-fake.conf /etc/init/fake-container-events.conf
|
||||
|
||||
# undo some leet hax of the base image
|
||||
RUN rm /usr/sbin/policy-rc.d; \
|
||||
rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl
|
||||
# remove some pointless services
|
||||
RUN /usr/sbin/update-rc.d -f ondemand remove; \
|
||||
for f in \
|
||||
/etc/init/u*.conf \
|
||||
/etc/init/mounted-dev.conf \
|
||||
/etc/init/mounted-proc.conf \
|
||||
/etc/init/mounted-run.conf \
|
||||
/etc/init/mounted-tmp.conf \
|
||||
/etc/init/mounted-var.conf \
|
||||
/etc/init/hostname.conf \
|
||||
/etc/init/networking.conf \
|
||||
/etc/init/tty*.conf \
|
||||
/etc/init/plymouth*.conf \
|
||||
/etc/init/hwclock*.conf \
|
||||
/etc/init/module*.conf\
|
||||
; do \
|
||||
dpkg-divert --local --rename --add "$f"; \
|
||||
done; \
|
||||
echo '# /lib/init/fstab: cleared out for bare-bones Docker' > /lib/init/fstab
|
||||
# end things from ubuntu-upstart Dockerfile
|
||||
|
||||
RUN apt-get install -y \
|
||||
python-coverage \
|
||||
python-dev \
|
||||
python-httplib2 \
|
||||
python-jinja2 \
|
||||
python-keyczar \
|
||||
python-mock \
|
||||
python-nose \
|
||||
python-paramiko \
|
||||
python-pip \
|
||||
python-setuptools \
|
||||
python-virtualenv \
|
||||
python-yaml
|
||||
RUN pip install --upgrade jinja2 pycrypto
|
||||
RUN rm /etc/apt/apt.conf.d/docker-clean
|
||||
RUN /bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
RUN mkdir /etc/ansible/
|
||||
RUN /bin/echo -e "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
|
||||
RUN locale-gen en_US.UTF-8
|
||||
RUN ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa && \
|
||||
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
|
||||
for key in /etc/ssh/ssh_host_*_key.pub; do echo "localhost $(cat ${key})" >> /root/.ssh/known_hosts; done
|
||||
ENV container docker
|
||||
CMD ["/sbin/init"]
|
@ -0,0 +1,13 @@
|
||||
# fake some events needed for correct startup other services
|
||||
|
||||
description "In-Container Upstart Fake Events"
|
||||
|
||||
start on startup
|
||||
|
||||
script
|
||||
rm -rf /var/run/*.pid
|
||||
rm -rf /var/run/network/*
|
||||
/sbin/initctl emit stopped JOB=udevtrigger --no-wait
|
||||
/sbin/initctl emit started JOB=udev --no-wait
|
||||
/sbin/initctl emit runlevel RUNLEVEL=3 --no-wait
|
||||
end script
|
@ -0,0 +1,66 @@
|
||||
FROM ubuntu:trusty
|
||||
RUN apt-get clean; apt-get update -y;
|
||||
RUN apt-get install -y \
|
||||
debianutils \
|
||||
gawk \
|
||||
git \
|
||||
locales \
|
||||
make \
|
||||
mercurial \
|
||||
ruby \
|
||||
subversion \
|
||||
sudo \
|
||||
openssh-client \
|
||||
openssh-server \
|
||||
unzip
|
||||
|
||||
# helpful things taken from the ubuntu-upstart Dockerfile:
|
||||
# https://github.com/tianon/dockerfiles/blob/4d24a12b54b75b3e0904d8a285900d88d3326361/sbin-init/ubuntu/upstart/14.04/Dockerfile
|
||||
ADD init-fake.conf /etc/init/fake-container-events.conf
|
||||
|
||||
# undo some leet hax of the base image
|
||||
RUN rm /usr/sbin/policy-rc.d; \
|
||||
rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl
|
||||
# remove some pointless services
|
||||
RUN /usr/sbin/update-rc.d -f ondemand remove; \
|
||||
for f in \
|
||||
/etc/init/u*.conf \
|
||||
/etc/init/mounted-dev.conf \
|
||||
/etc/init/mounted-proc.conf \
|
||||
/etc/init/mounted-run.conf \
|
||||
/etc/init/mounted-tmp.conf \
|
||||
/etc/init/mounted-var.conf \
|
||||
/etc/init/hostname.conf \
|
||||
/etc/init/networking.conf \
|
||||
/etc/init/tty*.conf \
|
||||
/etc/init/plymouth*.conf \
|
||||
/etc/init/hwclock*.conf \
|
||||
/etc/init/module*.conf\
|
||||
; do \
|
||||
dpkg-divert --local --rename --add "$f"; \
|
||||
done; \
|
||||
echo '# /lib/init/fstab: cleared out for bare-bones Docker' > /lib/init/fstab
|
||||
# end things from ubuntu-upstart Dockerfile
|
||||
|
||||
RUN apt-get install -y \
|
||||
python-coverage \
|
||||
python-httplib2 \
|
||||
python-jinja2 \
|
||||
python-keyczar \
|
||||
python-mock \
|
||||
python-nose \
|
||||
python-paramiko \
|
||||
python-pip \
|
||||
python-setuptools \
|
||||
python-virtualenv \
|
||||
python-yaml
|
||||
RUN rm /etc/apt/apt.conf.d/docker-clean
|
||||
RUN /bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
RUN mkdir /etc/ansible/
|
||||
RUN /bin/echo -e "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
|
||||
RUN locale-gen en_US.UTF-8
|
||||
RUN ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa && \
|
||||
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
|
||||
for key in /etc/ssh/ssh_host_*_key.pub; do echo "localhost $(cat ${key})" >> /root/.ssh/known_hosts; done
|
||||
ENV container docker
|
||||
CMD ["/sbin/init"]
|
@ -0,0 +1,13 @@
|
||||
# fake some events needed for correct startup other services
|
||||
|
||||
description "In-Container Upstart Fake Events"
|
||||
|
||||
start on startup
|
||||
|
||||
script
|
||||
rm -rf /var/run/*.pid
|
||||
rm -rf /var/run/network/*
|
||||
/sbin/initctl emit stopped JOB=udevtrigger --no-wait
|
||||
/sbin/initctl emit started JOB=udev --no-wait
|
||||
/sbin/initctl emit runlevel RUNLEVEL=3 --no-wait
|
||||
end script
|
@ -0,0 +1,20 @@
|
||||
#!/bin/sh -x
|
||||
|
||||
if [ "${TARGET}" = "sanity" ]; then
|
||||
./test/code-smell/replace-urlopen.sh .
|
||||
./test/code-smell/use-compat-six.sh lib
|
||||
./test/code-smell/boilerplate.sh
|
||||
./test/code-smell/required-and-default-attributes.sh
|
||||
if test x"$TOXENV" != x'py24' ; then tox ; fi
|
||||
if test x"$TOXENV" = x'py24' ; then python2.4 -V && python2.4 -m compileall -fq -x 'module_utils/(a10|rax|openstack|ec2|gce).py' lib/ansible/module_utils ; fi
|
||||
else
|
||||
set -e
|
||||
export C_NAME="testAbull_$$_$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)"
|
||||
docker run -d --volume="${PWD}:/root/ansible:Z" --name "${C_NAME}" ${TARGET_OPTIONS} ansible/ansible:${TARGET} > /tmp/cid_${TARGET}
|
||||
docker exec -ti $(cat /tmp/cid_${TARGET}) /bin/sh -c "export TEST_FLAGS='${TEST_FLAGS}'; cd /root/ansible; . hacking/env-setup; (cd test/integration; LC_ALL=en_US.utf-8 make)"
|
||||
docker kill $(cat /tmp/cid_${TARGET})
|
||||
|
||||
if [ "X${TESTS_KEEP_CONTAINER}" = "X" ]; then
|
||||
docker rm "${C_NAME}"
|
||||
fi
|
||||
fi
|
@ -0,0 +1,13 @@
|
||||
#
|
||||
# Test requirements
|
||||
#
|
||||
|
||||
nose
|
||||
mock >= 1.0.1, < 1.1
|
||||
passlib
|
||||
coverage
|
||||
coveralls
|
||||
unittest2
|
||||
redis
|
||||
python3-memcached
|
||||
python-systemd
|
@ -0,0 +1,13 @@
|
||||
#
|
||||
# Test requirements
|
||||
#
|
||||
|
||||
nose
|
||||
mock >= 1.0.1, < 1.1
|
||||
passlib
|
||||
coverage
|
||||
coveralls
|
||||
unittest2
|
||||
redis
|
||||
python-memcached
|
||||
python-systemd
|
Loading…
Reference in New Issue