Generate inventory file and ssh configuration file for VM.
The default image is ubuntu 16.04. So the ansible user is
ubuntu.
Change-Id: Ie14ebcdcfbc24f045ffd32785eec07df5798c5fb
Signed-off-by: zhihui wu <wu.zhihui1@zte.com.cn>
flavor_name: qtip_flavor
stack_name: qtip_stack
image_name: qtip_image
+ansible_user: ubuntu
flavor: "{{ flavor_name }}"
keypair: QtipKey
external_network: "{{ external_network }}"
+ register: stack
+
+- name: generating inventory file
+ template:
+ src: hosts.j2
+ dest: ./hosts
+
+- name: generating ssh.cfg
+ template:
+ src: ssh.cfg.j2
+ dest: ./ssh.cfg
--- /dev/null
+localhost ansible_connection=local
+
+[SUT:children]
+compute
+
+[node-groups:children]
+compute
+
+[node-groups:vars]
+ansible_ssh_common_args=-F ./ssh.cfg
+
+[compute]
+{% for item in stack.stack.outputs %}
+{% if item.output_key == 'instance_ip' %}
+{{item.output_value}}
+{% endif %}
+{% endfor %}
--- /dev/null
+# Connect to target node
+
+{% for item in stack.stack.outputs %}
+{% if item.output_key == 'instance_ip' %}
+Host {{ item.output_value }}
+ HostName {{ item.output_value }}
+ User {{ ansible_user }}
+ IdentityFile {{ temp_dir }}/QtipKey
+{% endif %}
+
+{% endfor %}