Hi Team,
below is my playbook and j2 template i was failed to create a file
actually i am not comfortable wil jinja2 if any one can guide me
playbook:
- name: read data
set_fact:
vm_data: "{{ lookup('file', 'variables/vm_data.yaml') | from_yaml
}}"
tags:
- read_vm_data
- name: getting IP_scope
getip_scope:
csv_file: template/subnetsheet.csv
location_network: "{{ location_network }}"
register: vm_data
tags:
- getting_ip
- name: Free Ip-address
script:
cmd: ip.py "{{ vm_data.details.IP_Scope }}" "{{
vm_data.details.IP_Gateway }}"
executable: python
register: ip
delegate_to: "{{ delegate_host }}"
tags:
- getting_ip
- name:
debug:
var: ip.stdout
tags:
- getting_ip
- name: set_fact
set_fact:
vDS: "{{ vm_data.details.vDS }}"
vPG_Name: "{{ vm_data.details.vPG_Name }}"
vm_ipv4_address: "{{ ip.stdout | from_json |
json_query('vm_ipv4_address') }}"
vm_ipv4_netmask: "{{ ip.stdout | from_json |
json_query('vm_ipv4_netmask') }}"
vm_ipv4_gateway: "{{ ip.stdout | from_json |
json_query('vm_ipv4_gateway') }}"
tags:
- get_variables.tf
- name: creating var.tf
template:
src: template/win_variable.tf.j2
dest: terraform_config_files/Windows/variables.tf
tags:
- get_variables.tf
jinja2 template:
locals {
vm = yamldecode(file("/runner/project/variables/vm_data.yaml"))
}
variable "vsphere_insecure" {
type = bool
default = true
}
#credentials
variable "vsphere_username" {
type = string
sensitive = true
}
variable "vsphere_password" {
type = string
sensitive = true
}
variable "domain_admin_username" {
type = string
sensitive = true
}
variable "domain_admin_password" {
type = string
sensitive = true
}
variable "vm_admin_password" {
type = string
sensitive = true
}
variable "template_name" {
type = string
default = "z_Templates/{{vsphere_template}}"
}
variable "vsphere_network" {
type = string
default = "{{ansible_facts[vDS]}}/{{ansible_facts[vPG Name]}}"
}
variable "vm_ipv4_address" {
type = string
default = {{ ansible_facts['vm_ipv4_address'] }}
}
variable "vm_ipv4_netmask" {
type = string
default = {{ ansible_facts['vm_ipv4_netmask'] }}
}
variable "vm_ipv4_gateway" {
type = string
default = {{ ansible_facts['vm_ipv4_gateway'] }}
}
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CALyK%3Dg8NAegmE5_-9QPmkzXv3RSkE1u5zkEAswyT9jc0s-pJDw%40mail.gmail.com.