Hello all
I am trying to get started with CloudStack provisioning, and am running into a problem. I have a task defined which should do 3 actions:
- Instantiate 2 VMs (linsrv04 & linsrv05)
- Open ports in the firewall
- Create a portforward from the opened public port to the VM.
Steps 1 & 2 finish successfully: However, task 3 fails.
$ ansible-playbook -i inventory.yml cloudstack_provision.yml
PLAY [Provision, or ensure as provisioned, VM instances in the BT Cloud.] *******************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************
ok: [linsrv05]
ok: [linsrv04]TASK [cloudstack_provision : Build VM or ensure it is already established.] *****************************************************************************************
ok: [linsrv04 → localhost]
ok: [linsrv05 → localhost]TASK [cloudstack_provision : Ensure ports opened on Public IP address] **********************************************************************************************
ok: [linsrv04 → localhost]
ok: [linsrv05 → localhost]TASK [cloudstack_provision : Ensure firewall port(s) opened and forward ports from public port to private port.] ****************************************************
fatal: [linsrv05 → localhost]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Virtual machine ‘linsrv05’ not found”}
fatal: [linsrv04 → localhost]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Virtual machine ‘linsrv05’ not found”}
to retry, use: --limit @/home/drose/ansible/cloudstack_provision.retryPLAY RECAP **********************************************************************************************************************************************************
linsrv04 : ok=3 changed=0 unreachable=0 failed=1
linsrv05 : ok=3 changed=0 unreachable=0 failed=1
re-running in -vvvv mode, I see the following for the failure:
fatal: [linsrv04 → localhost]: FAILED! => {
“changed”: false,
“failed”: true,
“invocation”: {
“module_args”: {
“account”: null,
“api_http_method”: “get”,
“api_key”: null,
“api_region”: “Dave_CMS4”,
“api_secret”: null,
“api_timeout”: 10,
“api_url”: null,
“domain”: null,
“ip_address”: “75.124.77.62”,
“network”: null,
“open_firewall”: false,
“poll_async”: true,
“private_end_port”: null,
“private_port”: 22,
“project”: null,
“protocol”: “tcp”,
“public_end_port”: null,
“public_port”: 2222,
“state”: “present”,
“vm”: “linsrv05”,
“vm_guest_ip”: null,
“vpc”: null,
“zone”: null
}
},
“msg”: “Virtual machine ‘linsrv05’ not found”
}
fatal: [linsrv05 → localhost]: FAILED! => {
“changed”: false,
“failed”: true,
“invocation”: {
“module_args”: {
“account”: null,
“api_http_method”: “get”,
“api_key”: null,
“api_region”: “Dave_CMS4”,
“api_secret”: null,
“api_timeout”: 10,
“api_url”: null,
“domain”: null,
“ip_address”: “75.124.77.62”,
“network”: null,
“open_firewall”: false,
“poll_async”: true,
“private_end_port”: null,
“private_port”: 22,
“project”: null,
“protocol”: “tcp”,
“public_end_port”: null,
“public_port”: 2322,
“state”: “present”,
“vm”: “linsrv05”,
“vm_guest_ip”: null,
“vpc”: null,
“zone”: null
}
},
“msg”: “Virtual machine ‘linsrv05’ not found”
}
to retry, use: --limit @/home/drose/ansible/cloudstack_provision.retry
I don’t understand why I have the specific error the VMs can’t be found. Here is a slightly edited list of VMs running in the cloud account …
Name State Offering Zone Account IP’s
linsrv04 Running 1vCPU-2660MHz-4GB-RAM US-NEW-NUT-G-V-A-R-S-001 Cloud_Compute_USD.rose@**.com 10.1.0.22
linsrv05 Running 1vCPU-2660MHz-4GB-RAM US-NEW-NUT-G-V-A-R-S-001 Cloud_Compute_USD.rose@**.com 10.1.0.23
Total number of virtual machines: 11
Here is the task/main.yml file:
- name: Build VM or ensure it is already established.
local_action:
module : cs_instance
api_region : “{{ api_region }}” ## This is in the ./cloudstack.ini file.
name : “{{ inventory_hostname_short }}”
service_offering : “{{ cs_1cpu4gb }}”
template : “{{ iso_template }}”
ip_to_networks :- network : “{{ network }}”
ip : “{{ ansible_host }}”
zone : “{{ cs_zone }}”
state : started
- name: Ensure ports opened on Public IP address
local_action:
module : cs_firewall
api_region : “{{ api_region }}” ## This is in the ./cloudstack.ini file.
cidr : 0.0.0.0/0
ip_address : “{{ public_ip }}” ## This is the IP Address of the internal VM.
port : “{{ ansible_ssh_public_port }}” ## Open the public port.when : public_ip is defined
- name: Ensure firewall port(s) opened and forward ports from public port to private port.
local_action:
module : cs_portforward
api_region : “{{ api_region }}” ## This is in the ./cloudstack.ini file.
ip_address : “{{ public_ip }}” ## This is the Public IP Address
vm : “{{ inventory_hostname }}”
public_port : “{{ ansible_ssh_public_port }}”
private_port : “{{ ansible_ssh_port }}”
protocol : tcpopen_firewall : true
Appreciate any help or direction anyone can provide …
-dave