Commit aede9435a93d5aaffe51a310cdeb38a496039dfc

Authored by Antonio Terceiro
1 parent b02ece51
Exists in master and in 90 other branches 3.x, add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup, backup_not_prod, cdtc_configuration, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev-lappis, dev_env_minimal, disable_email_dev, docs, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, performance, prezento, r3, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_backup_emails, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, stable-devel, support_docs, syslog, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

centralize IP configuration for development environment

Rakefile
1   -if !File.exist?('.ssh_config')
2   - sh "vagrant ssh-config > .ssh_config"
3   -end
4   -
5 1 require 'chake'
6 2  
7 3 task :test do
... ... @@ -11,3 +7,15 @@ task :test do
11 7 end
12 8  
13 9 task :default => :test
  10 +
  11 +file 'ssh_config.erb'
  12 +file '.ssh_config' => ['nodes.yaml', 'ssh_config.erb'] do |t|
  13 + require 'erb'
  14 + template = ERB.new(File.read('ssh_config.erb'))
  15 + File.open(t.name, 'w') do |f|
  16 + f.write(template.result(binding))
  17 + end
  18 + puts 'ERB %s' % t.name
  19 +end
  20 +
  21 +task :bootstrap_common => '.ssh_config'
... ...
Vagrantfile
1 1 # -*- mode: ruby -*-
2 2 # vi: set ft=ruby :
3 3  
  4 +require 'yaml'
  5 +
4 6 # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5 7 VAGRANTFILE_API_VERSION = "2"
6 8  
... ... @@ -11,20 +13,22 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
11 13 config.vm.provision 'shell', path: 'utils/proxy.sh', args: [proxy]
12 14 end
13 15  
  16 + ips = YAML.load_file('nodes.yaml').first[1]['peers']
  17 +
14 18 config.vm.define 'integration' do |integration|
15   - integration.vm.network 'private_network', ip: '10.1.1.1'
  19 + integration.vm.network 'private_network', ip: ips['integration']
16 20 end
17 21 config.vm.define 'email' do |email|
18   - email.vm.network 'private_network', ip: '10.1.1.2'
  22 + email.vm.network 'private_network', ip: ips['email']
19 23 end
20 24 config.vm.define 'social' do |social|
21   - social.vm.network 'private_network', ip: '10.1.1.3'
  25 + social.vm.network 'private_network', ip: ips['social']
22 26 end
23 27 config.vm.define 'database' do |database|
24   - database.vm.network 'private_network', ip: '10.1.1.4'
  28 + database.vm.network 'private_network', ip: ips['database']
25 29 end
26 30 config.vm.define 'reverseproxy' do |reverseproxy|
27   - reverseproxy.vm.network 'private_network', ip: '10.1.1.5'
  31 + reverseproxy.vm.network 'private_network', ip: ips['reverseproxy']
28 32 reverseproxy.vm.network 'forwarded_port', guest: 80, host: 8080
29 33 reverseproxy.vm.network 'forwarded_port', guest: 443, host: 8443
30 34 end
... ...
nodes.yaml
... ... @@ -3,11 +3,11 @@ vagrant@integration:
3 3 - role[server]
4 4 - role[integration_server]
5 5 peers: &PEERS
6   - integration: 10.1.1.1
7   - email: 10.1.1.2
8   - social: 10.1.1.3
9   - database: 10.1.1.4
10   - reverseproxy: 10.1.1.5
  6 + integration: 10.10.10.2
  7 + email: 10.10.10.3
  8 + social: 10.10.10.4
  9 + database: 10.10.10.5
  10 + reverseproxy: 10.10.10.6
11 11 vagrant@email:
12 12 run_list:
13 13 - role[server]
... ...
ssh_config.erb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +Host *
  2 + User vagrant
  3 + UserKnownHostsFile /dev/null
  4 + StrictHostKeyChecking no
  5 + PasswordAuthentication no
  6 + IdentitiesOnly yes
  7 + LogLevel FATAL
  8 +
  9 +<% $nodes.each do |node| %>
  10 +Host <%= node.hostname %>
  11 + Hostname <%= node.data['peers'][node.hostname] %>
  12 + IdentityFile <%= (Dir.glob(".vagrant/machines/#{node.hostname}/*/private_key") + [File.expand_path('~/.vagrant.d/insecure_private_key')]).find { |f| File.exists?(f) }.tap { |f| File.expand_path(f) } %>
  13 +<% end %>
  14 +
  15 +# vim: ft=sshconfig
... ...