ansible-2.x

Ansible - when conditional not working for vars_prompt at playbook level

人走茶凉 提交于 2021-01-27 19:33:38
问题 ansible 2.1.2.0 I have a situation here for which I'm trying to check with you all to see if the solution is even possible with Ansible vars_prompt feature and when conditional. Ansible has this feature called: vars_prompt and I want to club this with the when conditional ( when: ... which we generally use in tasks at task or playbook level actions) PS: My question is different than this post : Ansible to Conditionally Prompt for a Variable? i.e. my vars: variables are not dependent upon any

Ansible with_dict expects a dict

∥☆過路亽.° 提交于 2021-01-27 05:06:20
问题 I know this question has been asked many times before but I must be missing something here! This is a minimal playbook to reproduce the issue. Here is the playbook: --- - hosts: - localhost gather_facts: false vars: zones_hash: location1: id: 1 control_prefix: '10.1.254' data_prefix: '10.1.100' location2: id: 2 control_prefix: '10.2.254' data_prefix: '10.2.100' tasks: - name: "test1" debug: var="zones_hash" - name: "test2" debug: var="item" with_dict: - "{{ zones_hash }}" Here is the output:

Ansible with_dict expects a dict

狂风中的少年 提交于 2021-01-27 05:05:56
问题 I know this question has been asked many times before but I must be missing something here! This is a minimal playbook to reproduce the issue. Here is the playbook: --- - hosts: - localhost gather_facts: false vars: zones_hash: location1: id: 1 control_prefix: '10.1.254' data_prefix: '10.1.100' location2: id: 2 control_prefix: '10.2.254' data_prefix: '10.2.100' tasks: - name: "test1" debug: var="zones_hash" - name: "test2" debug: var="item" with_dict: - "{{ zones_hash }}" Here is the output:

Ansible with_dict expects a dict

最后都变了- 提交于 2021-01-27 05:05:34
问题 I know this question has been asked many times before but I must be missing something here! This is a minimal playbook to reproduce the issue. Here is the playbook: --- - hosts: - localhost gather_facts: false vars: zones_hash: location1: id: 1 control_prefix: '10.1.254' data_prefix: '10.1.100' location2: id: 2 control_prefix: '10.2.254' data_prefix: '10.2.100' tasks: - name: "test1" debug: var="zones_hash" - name: "test2" debug: var="item" with_dict: - "{{ zones_hash }}" Here is the output:

Concatenate strings using with_items and assign to a variable in Ansible

房东的猫 提交于 2020-12-06 12:31:06
问题 I need to save two 2 IPs to a variable in a vars_file when launching ec2_instances, which are used later during deployment. This is how I am saving a single server ip: - name: Save server public IP to vars file lineinfile: line="server_public_ip{{':'}} {{ item.public_ip }}" dest="{{ansible_env.HOME}}/dynamic_ips_{{ec2_environment}}" with_items: server.instances #server is registered in previous task The output I have in dynamic_ips file is server_public_ip: xxx.xxx.xx.x Now I have 2 servers