Giter Site home page Giter Site logo

Comments (4)

giovannicandido avatar giovannicandido commented on May 19, 2024

Vagrantfile:

require 'yaml'
settings = YAML.load_file 'vagrant.yml'

Vagrant.configure("2") do |config|

  config.vm.define :kmaster do |machine|

    machine.vm.box = "giovanni/xenial64-libvirt"
    machine.vm.hostname = "kmaster"

    machine.vm.network "private_network", ip: settings['kmaster_ip_address']

    machine.vm.provider :libvirt do |domain|
      domain.memory = 1024
      domain.cpus = 2
      domain.storage :file, :size => settings['docker_disk_size'], :device => settings['docker_disk']
    end
  end

  config.vm.define :node1 do |machine|

    machine.vm.box = "giovanni/xenial64-libvirt"
    machine.vm.hostname = "node1"

    machine.vm.network "private_network", ip: settings['node1_ip_address']

    machine.vm.provider :libvirt do |domain|
      domain.memory = 1024
      domain.cpus = 2
      domain.storage :file, :size => settings['docker_disk_size'], :device => settings['docker_disk']      
    end
    
  end

  config.vm.define :node2 do |machine|

    machine.vm.box = "giovanni/xenial64-libvirt"
    machine.vm.hostname = "node2"

    machine.vm.network "private_network", ip: settings['node2_ip_address']

    machine.vm.provider :libvirt do |domain|
      domain.memory = 1024
      domain.cpus = 2
      domain.storage :file, :size => settings['docker_disk_size'], :device => settings['docker_disk']
    end
  end
  
  config.vm.define :node3 do |machine|

    machine.vm.box = "giovanni/xenial64-libvirt"
    machine.vm.hostname = "node2"

    machine.vm.network "private_network", ip: settings['node3_ip_address']

    machine.vm.provider :libvirt do |domain|
      domain.memory = 1024
      domain.cpus = 2
      domain.storage :file, :size => settings['docker_disk_size'], :device => settings['docker_disk']
    end
  end

  config.vm.provision "ansible" do |ansible|
    ansible.sudo = true
    ansible.groups = {
      "docker" => ["kmaster", "node1", "node2", "node3"],
      "cluster_nodes" => ["node1", "node2", "node3"],
      "cluster_servers" => ["node1", "node2"]
    }
    ansible.host_vars = {
      "kmaster" => {"private_ip_address" => settings['kmaster_ip_address']},  
      "node1" => {"consul_node_role" => "bootstrap", "private_ip_address" => settings['node1_ip_address']}, 
      "node2" => {"consul_node_role" => "server", "private_ip_address" => settings['node2_ip_address']},  
      "node3" => {"consul_node_role" => "server", "private_ip_address" => settings['node3_ip_address']}
    }
    ansible.playbook = "devsite.yml"
  end
  config.vm.synced_folder ".", "/mnt", disabled: true
end

Ansible provision:

---
- hosts: docker
  roles:
    - docker
- hosts: cluster_nodes
  become: yes
  become_user: root
  roles:
    - name: brianshumate.consul
      consul_iface: "{{ private_interface | mandatory}}"
      consul_install_remotely: true

Vagrant inventory

# Generated by Vagrant

kmaster ansible_ssh_host=192.168.121.61 ansible_ssh_port=22 ansible_ssh_user='vagrant' ansible_ssh_private_key_file='/home/giovanni/Projects/atende/infra-barebones/.vagrant/machines/kmaster/libvirt/private_key' private_ip_address=192.168.50.2
node1 ansible_ssh_host=192.168.121.235 ansible_ssh_port=22 ansible_ssh_user='vagrant' ansible_ssh_private_key_file='/home/giovanni/Projects/atende/infra-barebones/.vagrant/machines/node1/libvirt/private_key' consul_node_role=bootstrap private_ip_address=192.168.50.3
node2 ansible_ssh_host=192.168.121.216 ansible_ssh_port=22 ansible_ssh_user='vagrant' ansible_ssh_private_key_file='/home/giovanni/Projects/atende/infra-barebones/.vagrant/machines/node2/libvirt/private_key' consul_node_role=server private_ip_address=192.168.50.4
node3 ansible_ssh_host=192.168.121.183 ansible_ssh_port=22 ansible_ssh_user='vagrant' ansible_ssh_private_key_file='/home/giovanni/Projects/atende/infra-barebones/.vagrant/machines/node3/libvirt/private_key' consul_node_role=server private_ip_address=192.168.50.5

[docker]
kmaster
node1
node2
node3

[cluster_nodes]
node1
node2
node3

[cluster_servers]
node1
node2

from ansible-consul.

giovannicandido avatar giovannicandido commented on May 19, 2024

Don't know why, but using just:

consul_node_role: server 
consul_bootstrap_expect: true

Works. Now I going to try join the nodes, I will do feedback soon.

Thank you all for the work on this role, makes life easy for everyone ;-)

from ansible-consul.

giovannicandido avatar giovannicandido commented on May 19, 2024

Working good, but I have to define consul_raw_key to some value, destroy and recreate the cluster

from ansible-consul.

giovannicandido avatar giovannicandido commented on May 19, 2024

Problem is Vagrant no provisioning in parallel, have to set ansible.limit = "all" in vagrant file

from ansible-consul.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.