content: |
version: 5
hierarchy:
- - name: ansible
- path: vars.json
+ - name: hostvars
+ path: hostvars.json
data_hash: json_data
+ - name: this
+ path: this.json
+ data_hash: json_data
+ delegate_to: 127.0.0.1
+ - name: dump hostvars
+ copy:
+ dest: "{{ local_temp.path }}/data/hostvars.json"
+ content: "{'hostvars': {{ hostvars }} }"
+ delegate_to: 127.0.0.1
+ - name: dump this
+ copy:
+ dest: "{{ local_temp.path }}/data/this.json"
+ content: "{{ hostvars[inventory_hostname] }}"
+ delegate_to: 127.0.0.1
+ - name: get facts
+ command: facter -y
+ register: facter_output
+ - name: create facts directory in local temp
+ file:
+ path: "{{ local_temp.path }}/yaml/facts"
+ state: directory
delegate_to: 127.0.0.1
- - name: dump all vars
+ - name: dump facts
copy:
- dest: "{{ local_temp.path }}/data/vars.json"
- content: "{{ hostvars }}"
+ dest: "{{ local_temp.path }}/yaml/facts/{{ inventory_hostname }}.yaml"
+ content: "--- !ruby/object:Puppet::Node::Facts\nvalues:\n {{ facter_output.stdout | indent(width=2) }}"
delegate_to: 127.0.0.1
- name: compile catalogs
- command: puppet catalog compile --modulepath={{ inventory_dir }}/puppet/modules --hiera_config={{ local_temp.path }}/hiera.yaml --manifest={{ inventory_dir }}/puppet/site --terminus compiler {{ inventory_hostname }}
- environment:
- FACTER_ansible_inventory_hostname: "{{ inventory_hostname }}"
+ command: puppet catalog compile --modulepath={{ inventory_dir }}/puppet/modules --hiera_config={{ local_temp.path }}/hiera.yaml --manifest={{ inventory_dir }}/puppet/site --terminus compiler --vardir {{ local_temp.path }}/ --facts_terminus yaml {{ inventory_hostname }}
delegate_to: 127.0.0.1
register: catalog
- name: install puppet
include automatic_updates
-$tinc_hosts = lookup("'$ansible_inventory_hostname'.groups.tinc")
-$tinc_other_hosts = $tinc_hosts.filter |$host_name| { $host_name != $ansible_inventory_hostname }
+$tinc_hosts = lookup("groups.tinc")
+$tinc_other_hosts = $tinc_hosts.filter |$host_name| { $host_name != $facts["networking"]["fqdn"] }
$tinc_locations = Hash($tinc_hosts.map |$host_name| { [
- lookup("'$host_name'.network.tinc.location"),
+ lookup("hostvars.'$host_name'.network.tinc.location"),
{
- subnet => lookup("'$host_name'.network.self_internal_network"),
- address => lookup("'$host_name'.network.public_hostname"),
+ subnet => lookup("hostvars.'$host_name'.network.self_internal_network"),
+ address => lookup("hostvars.'$host_name'.network.public_hostname"),
}
] })
-$tinc_connect_to = $tinc_other_hosts.map |$host_name| { lookup("'$host_name'.network.tinc.location") }
+$tinc_connect_to = $tinc_other_hosts.map |$host_name| { lookup("hostvars.'$host_name'.network.tinc.location") }
-$tinc_other_networks = $tinc_other_hosts.map |$host_name| { lookup("'$host_name'.network.self_internal_network") }
+$tinc_other_networks = $tinc_other_hosts.map |$host_name| { lookup("hostvars.'$host_name'.network.self_internal_network") }
-if 'tinc' in lookup("'$ansible_inventory_hostname'.group_names") {
+if 'tinc' in lookup("group_names") {
class {'tinc':
- tinc_name => lookup("'$ansible_inventory_hostname'.tinc_global.name"),
- tinc_location => lookup("'$ansible_inventory_hostname'.network.tinc.location"),
+ tinc_name => lookup("tinc_global.name"),
+ tinc_location => lookup("network.tinc.location"),
tinc_connect_to => $tinc_connect_to,
tinc_locations => $tinc_locations,
- tinc_ip => lookup("'$ansible_inventory_hostname'.network.self_internal_ip"),
- tinc_netmask => lookup("'$ansible_inventory_hostname'.network.self_internal_netmask"),
+ tinc_ip => lookup("network.self_internal_ip"),
+ tinc_netmask => lookup("network.self_internal_netmask"),
tinc_other_networks => $tinc_other_networks,
}
}