Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to share a hosts file between vagrant and puppet
    primarykey
    data
    text
    <p>I am currently converting a large number of EC2 instances to a series of puppet scripts and then using Vagrant to virtualise the rig for local development.</p> <p>I have gotten stuck on managing the network in vagrant and mapping that onto production.</p> <p>First I have something like this:</p> <pre><code># Main Web Server config.vm.define :app do |app_config| app_config.vm.host_name = "web1" app_config.vm.network :hostonly, "10.0.0.2" app_config.vm.box = "precise64" ...etc puppet.manifest_file = "persist/web.pp" end # First DB server config.vm.define :db1 do |db1_config| db1_config.vm.host_name = "db1" db1_config.vm.network :hostonly, "10.0.0.3" db1_config.vm.box = "precise64" ...etc puppet.manifest_file = "persist/db.pp" end etc. </code></pre> <p>Then in this case web.pp and db.pp are reasonably simply they just setup python, uwsgi, nginx, mysql etc.</p> <p>So the problem: I need inside for example <code>puppet/modules/hosts/files/hosts</code> have to specify something like:</p> <pre><code>10.0.0.3 db1.X.com 10.0.0.4 db2.X.com etc. </code></pre> <p>In production we use a combination of our sites DNS and ec2 instances DNS records (which I cant put into hosts). Typically our haproxy hosts have a public DNS record and they hold the EC2 names in their config (which makes using a hosts file impossible).</p> <p>So how can I build a file that both puppet and vagrant can import and use a global mapping such as:</p> <pre><code>hosts = { web =&gt; 10.0.0.2, db1 =&gt; 10.0.0.3, db2 =&gt; 10.0.0.4, } </code></pre> <p>Which I can access from within puppet templates for example <code>haproxy.cfg</code> but also access from within Vagrant files so i can set <code>vm.network</code> to it as well.</p> <p>Restrictions:</p> <ul> <li>Cannot be IP only, must be symbolic name to either IP or DNS</li> <li>Cannot use a puppet master (unfortunately not flexible on this one).</li> <li>Virtualising the DNS server as well seems messy so id rather not.</li> </ul> <p>Also I am <strong>really</strong> new to ruby, if you provide examples (which would be great) please describe it enough for me to be able to find my way through the ruby docs.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload