Skip to content

Commit

Permalink
Expose load balancer IP address, set DNS server on consul-nomad nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
fhemberger committed Apr 16, 2020
1 parent 5fe664b commit 49e4d73
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Vagrantfile
Expand Up @@ -28,7 +28,8 @@ Vagrant.configure(2) do |config|
ansible.groups = {
"consul_nomad" => ["consul-nomad-node[1:#{$max_nodes}]"],
"all:vars" => {
"vagrant_consul_nomad_ips" => $all_nodes
"vagrant_consul_nomad_ips" => $all_nodes,
"vagrant_loadbalancer_ip" => "#{get_ip(0)}"
}
}
end
Expand Down
1 change: 1 addition & 0 deletions group_vars/all.yml
Expand Up @@ -18,3 +18,4 @@ network_interface_ipv4: "{{ hostvars[inventory_hostname]['ansible_' + network_in
# When provisioned with Vagrant, use the list `vagrant_consul_nomad_ips` passed
# as group variable. Otherwise use `ansible_host` from the inventory file.
consul_nomad_ips: "{{ vagrant_consul_nomad_ips | default(groups['consul_nomad'] | map('extract', hostvars, 'ansible_host') | list) }}"
loadbalancer_ip: "{{ vagrant_loadbalancer_ip | default(hostvars['loadbalancer']['ansible_host']) }}"
13 changes: 13 additions & 0 deletions playbook.yml
Expand Up @@ -8,6 +8,19 @@
- name: consul
- name: nomad

post_tasks:
- name: Disable systemd-resolved service
systemd:
name: systemd-resolved
state: stopped
enabled: no

- name: Set nameserver to localhost
copy:
content: "nameserver {{ loadbalancer_ip }}"
dest: /etc/resolv.conf


- hosts: loadbalancer
become: yes
roles:
Expand Down

0 comments on commit 49e4d73

Please sign in to comment.