New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vagrantfile:104:in `block in <top (required)>': undefined method `[]' for nil:NilClass (NoMethodError) #1258

Closed
kusmierz opened this Issue Dec 9, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@kusmierz
Copy link

kusmierz commented Dec 9, 2014

After update and

vagrant up

I've error:

/home/adam/Projects/foobar/Vagrantfile:104:in `block in <top (required)>': undefined method `[]' for nil:NilClass (NoMethodError)
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/config/v2/loader.rb:37:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/config/v2/loader.rb:37:in `load'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/config/loader.rb:103:in `block (2 levels) in load'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/config/loader.rb:97:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/config/loader.rb:97:in `block in load'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/config/loader.rb:94:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/config/loader.rb:94:in `load'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/vagrantfile.rb:28:in `initialize'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/environment.rb:614:in `new'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/environment.rb:614:in `vagrantfile'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/environment.rb:399:in `host'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/environment.rb:198:in `block in action_runner'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/action/runner.rb:33:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/action/runner.rb:33:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/environment.rb:386:in `hook'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.6.5/lib/vagrant/environment.rb:596:in `unload'
    from /opt/vagrant/bin/../embedded/gems/gems/vagrant-1.6.5/bin/vagrant:177:in `ensure in <main>'
    from /opt/vagrant/bin/../embedded/gems/gems/vagrant-1.6.5/bin/vagrant:177:in `<main>'
---
vagrantfile-local:
    vm:
        box: puphpet/ubuntu1404-x64
        box_url: puphpet/ubuntu1404-x64
        hostname: foobar.dev
        memory: '2048'
        cpus: '2'
        chosen_provider: virtualbox
        network:
            private_network: 192.168.56.101
            forwarded_port:
                NsF0ppllVWzV:
                    host: '4040'
                    guest: '4040'
                b1FogaoYR5GU:
                    host: '8288'
                    guest: '22'
        post_up_message: ''
        provider:
            virtualbox:
                modifyvm:
                    natdnshostresolver1: on
            vmware:
                numvcpus: 1
            parallels:
                cpus: 1
        provision:
            puppet:
                manifests_path: puphpet/puppet
                manifest_file: site.pp
                module_path: puphpet/puppet/modules
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
                    - '--parser future'
        synced_folder:
            G6FvvpxcIvf6:
                owner: ''
                group: ''
                source: ./
                target: /var/www/foobar/
                sync_type: nfs
                rsync:
                    args:
                        - '--verbose'
                        - '--archive'
                        - '-z'
                    exclude:
                        - .vagrant/
                    auto: 'false'
        usable_port_range:
            start: 10200
            stop: 10500
    ssh:
        host: null
        port: null
        private_key_path: null
        username: vagrant
        guest_port: null
        keep_alive: true
        forward_agent: false
        forward_x11: false
        shell: 'bash -l'
    vagrant:
        host: detect
vagrantfile-rackspace:
    vm:
        box: rackspace
        hostname: master
        provider:
            rackspace:
                server_name: rackspace-server
                image: b279d8e6-1cbd-4e7c-875a-f6dbffc4c4a0
                region: dfw
                size: '512MB Standard Instance'
                username: RACKSPACE_USERNAME
                api_key: RACKSPACE_API_KEY
        provision:
            puppet:
                manifests_path: puphpet/puppet
                manifest_file: site.pp
                module_path: puphpet/puppet/modules
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
                    - '--parser future'
        synced_folder:
            OpDsgNpWBeev:
                source: ./
                target: /var/www
    ssh:
        host: null
        port: null
        private_key_path: ~/.ssh/id_rsa
        public_key_path: ~/.ssh/id_rsa.pub
        username: PRIVATE_KEY_USER
        guest_port: null
        keep_alive: true
        forward_agent: false
        forward_x11: false
        shell: 'bash -l'
    vagrant:
        host: detect
vagrantfile-linode:
    vm:
        box: linode
        hostname: master
        network:
            private_network: 192.168.56.101
            forwarded_port: {  }
        provider:
            linode:
                distribution: 'Debian 7.6'
                datacenter: newark
                plan: '1024'
                token: LINODE_API_KEY
                ssh_key_name: Vagrant
        provision:
            puppet:
                manifests_path: puphpet/puppet
                manifest_file: site.pp
                module_path: puphpet/puppet/modules
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
                    - '--parser future'
        synced_folder:
            OGZ7v7egFTdw:
                source: ./
                target: /var/www
    ssh:
        host: null
        port: null
        private_key_path: ~/.ssh/id_rsa
        username: PRIVATE_KEY_USER
        guest_port: null
        keep_alive: true
        forward_agent: false
        forward_x11: false
        shell: 'bash -l'
    vagrant:
        host: detect
vagrantfile-softlayer:
    vm:
        box: softlayer
        hostname: softlayer-server
        provider:
            softlayer:
                username: SOFTLAYER_USERNAME
                api_key: SOFTLAYER_API_KEY
                ssh_key: 'SOFTLAYER SAVED PUBLIC KEY NAME'
                operating_system: DEBIAN_7_64
                datacenter: ams01
                max_memory: '1024'
                start_cpus: '1'
                domain: test.com
        provision:
            puppet:
                manifests_path: puphpet/puppet
                manifest_file: site.pp
                module_path: puphpet/puppet/modules
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
                    - '--parser future'
        synced_folder:
            eKqZAGYzgua6:
                source: ./
                target: /var/www
    ssh:
        host: null
        port: null
        private_key_path: ~/.ssh/id_rsa
        public_key_path: null
        username: null
        guest_port: null
        keep_alive: true
        forward_agent: false
        forward_x11: false
        shell: 'bash -l'
    vagrant:
        host: detect
vagrantfile-aws:
    vm:
        box: aws
        hostname: master
        network:
            private_network: 192.168.56.101
            forwarded_port: {  }
        provider:
            aws:
                access_key_id: ''
                secret_access_key: ''
                keypair_name: ''
                ami: ami-4b124a22
                region: us-east-1
                instance_type: m1.small
                security_groups: {  }
                tags:
                    Source: Puphpet
        provision:
            puppet:
                manifests_path: puphpet/puppet
                manifest_file: site.pp
                module_path: puphpet/puppet/modules
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
                    - '--parser future'
        synced_folder:
            D4WCFjzUwduH:
                source: ./
                target: /var/www
    ssh:
        host: null
        port: null
        private_key_path: ~/.ssh/id_rsa
        username: admin
        guest_port: null
        keep_alive: true
        forward_agent: false
        forward_x11: false
        shell: 'bash -l'
    vagrant:
        host: detect
server:
    install: '1'
    packages:
        - vim
        - cron
        - anacron
        - curl
        - fluxbox
        - grep
        - gnupg
        - imagemagick
        - imagemagick-common
        - xvfb
        - phantomjs
        - git
        - git-core
        - git-flow
        - screen
        - htop
        - bmon
        - atop
        - iotop
        - lftp
        - libpcre3
        - libpcre3-dev
        - libssl-dev
        - zlib1g-dev
        - wget
        - tar
        - gzip
        - unrar
        - rar
        - bash-completion
        - ethstatus
        - ifstat
        - iftop
        - iptraf
        - host
        - links2
        - libdate-manip-perl
        - locate
        - sendmail
        - mailutils
        - mutt
        - util-linux
        - at
firewall:
    install: '1'
    rules: null
apache:
    install: '0'
    settings:
        user: www-data
        group: www-data
        default_vhost: true
        manage_user: false
        manage_group: false
        sendfile: 0
    modules:
        - rewrite
    vhosts:
        eFjYYfQQHDnf:
            servername: awesome.dev
            serveraliases:
                - www.awesome.dev
            docroot: /var/www/awesome
            port: '80'
            setenv:
                - 'APPLICATION_ENV vagrant'
            override:
                - All
            options:
                - Indexes
                - FollowSymLinks
                - MultiViews
            engine: php
            custom_fragment: ''
            ssl_cert: ''
            ssl_key: ''
            ssl_chain: ''
            ssl_certs_dir: ''
    mod_pagespeed: 0
nginx:
    install: '1'
    settings:
        default_vhost: 1
        proxy_buffer_size: 128k
        proxy_buffers: '4 256k'
    upstreams: {  }
    vhosts:
        Avv2qR8ckhf6:
            proxy: ''
            server_name: admin.foobar.dev
            server_aliases:
                - .admin.foobar.dev
            www_root: /var/www/foobar/admin/
            listen_port: '80'
            location: .php$
            index_files:
                - index.php
                - index.html
                - index.htm
            envvars:
                - 'APPLICATION_ENV vagrant'
            engine: php
            client_max_body_size: 1m
            ssl_cert: ''
            ssl_key: ''
        w4kJnlyFUqfn:
            proxy: ''
            server_name: foobar.dev
            server_aliases:
                - foobar.ngrok.com
                - .foobar.ngrok.com
                - .foobar.dev
            www_root: /var/www/foobar/public/
            listen_port: '80'
            location: .php$
            index_files:
                - index.php
                - index.html
                - index.htm
            envvars:
                - 'APPLICATION_ENV vagrant'
            engine: php
            client_max_body_size: 1m
            ssl_cert: ''
            ssl_key: ''
php:
    install: '1'
    version: '55'
    composer: '1'
    composer_home: ''
    modules:
        php:
            - cli
            - common
            - curl
            - gd
            - gmp
            - imagick
            - intl
            - mbstring
            - mcrypt
            - memcached
        pear: {  }
        pecl:
            - PDO
            - PDO_PGSQL
            - redis
            - date_time
            - timezonedb
            - gnupg
            - Fileinfo
            - zip
            - pecl_http
            - intl
            - big_int
            - uuid
            - igbinary
    ini:
        display_errors: On
        error_reporting: '-1'
        session.save_path: /var/lib/php/session
        short_open_tag: Off
        expose_php: Off
        max_execution_time: '120'
        max_input_time: '240'
        memory_limit: 1G
        display_startup_errors: On
        log_errors: On
        log_errors_max_len: '1024'
        error_log: /var/log/php/error.log
        ignore_repeated_errors: Off
        ignore_repeated_source: Off
        report_memleaks: On
        post_max_size: 32M
        upload_max_filesize: 32M
        cgi.fix_pathinfo: '0'
        filter.default: unsafe_raw
        default_charset: utf-8
        opcache.enable: '1'
        opcache.memory_consumption: '255'
        opcache.max_accelerated_files: '16384'
        opcache.revalidate_freq: '0'
        opcache.use_cwd: '1'
        opcache.validate_timestamps: '1'
        opcache.save_comments: '1'
        opcache.enable_file_override: '0'
        opcache.enable_cli: '1'
        opcache.file_update_protection: '0'
    timezone: Europe/Warsaw
    mod_php: 0
hhvm:
    install: '0'
    nightly: 0
    composer: '1'
    composer_home: ''
    settings:
        host: 127.0.0.1
        port: '9000'
    ini: {  }
    timezone: null
xdebug:
    install: '1'
    settings:
        xdebug.default_enable: '1'
        xdebug.remote_autostart: '0'
        xdebug.remote_host: 192.168.56.1
        xdebug.remote_enable: '1'
        xdebug.remote_mode: req
        xdebug.remote_handler: dbgp
        xdebug.remote_port: '9000'
        xdebug.scream: '0'
        xdebug.max_nesting_level: '250'
        xdebug.cli_color: '1'
        xdebug.profiler_enable: '0'
        xdebug.profiler_enable_trigger: '1'
        xdebug.profiler_output_name: profiler.out.%t.%p
        xdebug.trace_format: '1'
        xdebug.collect_assignments: '1'
        xdebug.collect_params: '3'
        xdebug.collect_return: '1'
        xdebug.collect_vars: '1'
        xdebug.show_local_vars: '0'
        xdebug.show_exception_trace: '0'
        xdebug.var_display_max_depth: '5'
        xdebug.var_display_max_children: '256'
        xdebug.var_display_max_data: '1024'
xhprof:
    install: '0'
wpcli:
    install: '0'
    version: null
drush:
    install: '0'
    version: 6.3.0
ruby:
    install: '1'
    versions:
        BFGimWLjwucF:
            default: '1'
            version: 2.1.2
            gems:
                - bourbon
                - compass
                - sass
            bundler: '1'
nodejs:
    install: '1'
    npm_packages:
        - bower
        - ngrok
        - requirejs
        - grunt
        - grunt-cli
python:
    install: '1'
    packages: {  }
    versions: {  }
mysql:
    install: '0'
    override_options: {  }
    root_password: '123'
    adminer: 0
    databases:
        NPjb4ADPDwGD:
            grant:
                - ALL
            name: dbname
            host: localhost
            user: dbuser
            password: '123'
            sql_file: ''
postgresql:
    install: '1'
    settings:
        root_password: '123'
        user_group: postgres
        encoding: UTF8
        version: '9.3'
    databases:
        kc0lLLSDrrKC:
            grant: ALL
            name: foobar
            user: foobar
            password: foobar
            sql_file: ''
    adminer: '1'
mariadb:
    install: '0'
    override_options: {  }
    root_password: '123'
    adminer: 0
    databases: {  }
    version: '10.0'
sqlite:
    install: '0'
    adminer: 0
    databases: {  }
mongodb:
    install: '0'
    settings:
        auth: 1
        port: '27017'
    databases: {  }
redis:
    install: '1'
    settings:
        conf_port: '6379'
mailcatcher:
    install: '1'
    settings:
        smtp_ip: 0.0.0.0
        smtp_port: 1025
        http_ip: 0.0.0.0
        http_port: '1080'
        mailcatcher_path: /usr/local/rvm/wrappers/default
        from_email_method: inline
beanstalkd:
    install: '1'
    settings:
        listenaddress: 0.0.0.0
        listenport: '13000'
        maxjobsize: '65535'
        maxconnections: '1024'
        binlogdir: /var/lib/beanstalkd/binlog
        binlogfsync: null
        binlogsize: '10485760'
    beanstalk_console: '1'
    binlogdir: /var/lib/beanstalkd/binlog
rabbitmq:
    install: '0'
    settings:
        port: '5672'
elastic_search:
    install: '0'
    settings:
        version: null
        java_install: true
solr:
    install: '0'
    settings:
        version: null
        port: ''
require 'yaml'

dir = File.dirname(File.expand_path(__FILE__))

configValues = YAML.load_file("#{dir}/puphpet/config.yaml")
data         = configValues['vagrantfile-local']

Vagrant.require_version '>= 1.6.0'

Vagrant.configure('2') do |config|
  config.vm.box     = "#{data['vm']['box']}"
  config.vm.box_url = "#{data['vm']['box_url']}"

  if data['vm']['hostname'].to_s.strip.length != 0
    config.vm.hostname = "#{data['vm']['hostname']}"
  end

  if data['vm']['network']['private_network'].to_s != ''
    config.vm.network 'private_network', ip: "#{data['vm']['network']['private_network']}"
  end

  data['vm']['network']['forwarded_port'].each do |i, port|
    if port['guest'] != '' && port['host'] != ''
      config.vm.network :forwarded_port, guest: port['guest'].to_i, host: port['host'].to_i
    end
  end

  if !data['vm']['post_up_message'].nil?
    config.vm.post_up_message = "#{data['vm']['post_up_message']}"
  end

  if Vagrant.has_plugin?('vagrant-hostmanager')
    hosts = Array.new()

    if !configValues['apache']['install'].nil? &&
        configValues['apache']['install'].to_i == 1 &&
        configValues['apache']['vhosts'].is_a?(Hash)
      configValues['apache']['vhosts'].each do |i, vhost|
        hosts.push(vhost['servername'])

        if vhost['serveraliases'].is_a?(Array)
          vhost['serveraliases'].each do |vhost_alias|
            hosts.push(vhost_alias)
          end
        end
      end
    elsif !configValues['nginx']['install'].nil? &&
           configValues['nginx']['install'].to_i == 1 &&
           configValues['nginx']['vhosts'].is_a?(Hash)
      configValues['nginx']['vhosts'].each do |i, vhost|
        hosts.push(vhost['server_name'])

        if vhost['server_aliases'].is_a?(Array)
          vhost['server_aliases'].each do |x, vhost_alias|
            hosts.push(vhost_alias)
          end
        end
      end
    end

    if hosts.any?
      if config.vm.hostname.to_s.strip.length == 0
        config.vm.hostname = 'puphpet-dev-machine'
      end

      config.hostmanager.enabled           = true
      config.hostmanager.manage_host       = true
      config.hostmanager.ignore_private_ip = false
      config.hostmanager.include_offline   = false
      config.hostmanager.aliases           = hosts
    end
  end

  if Vagrant.has_plugin?('vagrant-cachier')
    config.cache.scope = :box
  end

  data['vm']['synced_folder'].each do |i, folder|
    if folder['source'] != '' && folder['target'] != ''
      sync_owner = !folder['sync_owner'].nil? ? folder['sync_owner'] : 'www-data'
      sync_group = !folder['sync_group'].nil? ? folder['sync_group'] : 'www-data'

      if folder['sync_type'] == 'nfs'
        config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", type: 'nfs', mount_options: ['nolock,vers=3,udp,noatime']
      elsif folder['sync_type'] == 'smb'
        config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", type: 'smb'
      elsif folder['sync_type'] == 'rsync'
        rsync_args = !folder['rsync']['args'].nil? ? folder['rsync']['args'] : ['--verbose', '--archive', '-z']
        rsync_auto = !folder['rsync']['auto'].nil? ? folder['rsync']['auto'] : true
        rsync_exclude = !folder['rsync']['exclude'].nil? ? folder['rsync']['exclude'] : ['.vagrant/']

        config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}",
          rsync__args: rsync_args, rsync__exclude: rsync_exclude, rsync__auto: rsync_auto, type: 'rsync', group: sync_group, owner: sync_owner
      elsif data['vm']['chosen_provider'] == 'parallels'
        config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}",
          group: sync_group, owner: sync_owner, mount_options: ['share']
      else
        config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}",
          group: sync_group, owner: sync_owner, mount_options: ['dmode=775', 'fmode=764']
      end
    end
  end

  config.vm.usable_port_range = (data['vm']['usable_port_range']['start'].to_i..data['vm']['usable_port_range']['stop'].to_i)

  if data['vm']['chosen_provider'].empty? || data['vm']['chosen_provider'] == 'virtualbox'
    ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'

    config.vm.provider :virtualbox do |virtualbox|
      data['vm']['provider']['virtualbox']['modifyvm'].each do |key, value|
        if key == 'memory'
          next
        end
        if key == 'cpus'
          next
        end

        if key == 'natdnshostresolver1'
          value = value ? 'on' : 'off'
        end

        virtualbox.customize ['modifyvm', :id, "--#{key}", "#{value}"]
      end

      virtualbox.customize ['modifyvm', :id, '--memory', "#{data['vm']['memory']}"]
      virtualbox.customize ['modifyvm', :id, '--cpus', "#{data['vm']['cpus']}"]

      if data['vm']['provider']['virtualbox']['modifyvm']['name'].nil? ||
        data['vm']['provider']['virtualbox']['modifyvm']['name'].empty?
        if data['vm']['hostname'].to_s.strip.length != 0
          virtualbox.customize ['modifyvm', :id, '--name', config.vm.hostname]
        end
      end
    end
  end

  if data['vm']['chosen_provider'] == 'vmware_fusion' || data['vm']['chosen_provider'] == 'vmware_workstation'
    ENV['VAGRANT_DEFAULT_PROVIDER'] = (data['vm']['chosen_provider'] == 'vmware_fusion') ? 'vmware_fusion' : 'vmware_workstation'

    config.vm.provider :vmware_fusion do |v, override|
      data['vm']['provider']['vmware'].each do |key, value|
        if key == 'memsize'
          next
        end
        if key == 'cpus'
          next
        end

        v.vmx["#{key}"] = "#{value}"
      end

      v.vmx['memsize']  = "#{data['vm']['memory']}"
      v.vmx['numvcpus'] = "#{data['vm']['cpus']}"

      if data['vm']['provider']['vmware']['displayName'].nil? ||
        data['vm']['provider']['vmware']['displayName'].empty?
        if data['vm']['hostname'].to_s.strip.length != 0
          v.vmx['displayName'] = config.vm.hostname
        end
      end
    end
  end

  if data['vm']['chosen_provider'] == 'parallels'
    ENV['VAGRANT_DEFAULT_PROVIDER'] = 'parallels'

    config.vm.provider 'parallels' do |v|
      data['vm']['provider']['parallels'].each do |key, value|
        if key == 'memsize'
          next
        end
        if key == 'cpus'
          next
        end

        v.customize ['set', :id, "--#{key}", "#{value}"]
      end

      v.memory = "#{data['vm']['memory']}"
      v.cpus   = "#{data['vm']['cpus']}"

      if data['vm']['provider']['parallels']['name'].nil? ||
        data['vm']['provider']['parallels']['name'].empty?
        if data['vm']['hostname'].to_s.strip.length != 0
          v.name = config.vm.hostname
        end
      end
    end
  end

  ssh_username = !data['ssh']['username'].nil? ? data['ssh']['username'] : 'vagrant'

  config.vm.provision 'shell' do |s|
    s.path = 'puphpet/shell/initial-setup.sh'
    s.args = '/vagrant/puphpet'
  end
  config.vm.provision 'shell' do |kg|
    kg.path = 'puphpet/shell/ssh-keygen.sh'
    kg.args = "#{ssh_username}"
  end
  config.vm.provision :shell, :path => 'puphpet/shell/install-ruby.sh'
  config.vm.provision :shell, :path => 'puphpet/shell/install-puppet.sh'

  config.vm.provision :puppet do |puppet|
    puppet.facter = {
      'ssh_username'     => "#{ssh_username}",
      'provisioner_type' => ENV['VAGRANT_DEFAULT_PROVIDER'],
      'vm_target_key'    => 'vagrantfile-local',
    }
    puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}"
    puppet.manifest_file  = "#{data['vm']['provision']['puppet']['manifest_file']}"
    puppet.module_path    = "#{data['vm']['provision']['puppet']['module_path']}"

    if !data['vm']['provision']['puppet']['options'].empty?
      puppet.options = data['vm']['provision']['puppet']['options']
    end
  end

  config.vm.provision :shell do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['exec-once', 'exec-always']
  end
  config.vm.provision :shell, run: 'always' do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['startup-once', 'startup-always']
  end
  config.vm.provision :shell, :path => 'puphpet/shell/important-notices.sh'

  if File.file?("#{dir}/puphpet/files/dot/ssh/id_rsa")
    config.ssh.private_key_path = [
      "#{dir}/puphpet/files/dot/ssh/id_rsa",
      "#{dir}/puphpet/files/dot/ssh/insecure_private_key"
    ]
  end

  if !data['ssh']['host'].nil?
    config.ssh.host = "#{data['ssh']['host']}"
  end
  if !data['ssh']['port'].nil?
    config.ssh.port = "#{data['ssh']['port']}"
  end
  if !data['ssh']['username'].nil?
    config.ssh.username = "#{data['ssh']['username']}"
  end
  if !data['ssh']['guest_port'].nil?
    config.ssh.guest_port = data['ssh']['guest_port']
  end
  if !data['ssh']['shell'].nil?
    config.ssh.shell = "#{data['ssh']['shell']}"
  end
  if !data['ssh']['keep_alive'].nil?
    config.ssh.keep_alive = data['ssh']['keep_alive']
  end
  if !data['ssh']['forward_agent'].nil?
    config.ssh.forward_agent = data['ssh']['forward_agent']
  end
  if !data['ssh']['forward_x11'].nil?
    config.ssh.forward_x11 = data['ssh']['forward_x11']
  end
  if !data['vagrant']['host'].nil?
    config.vagrant.host = data['vagrant']['host'].gsub(':', '').intern
  end
end

require 'yaml'

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'rackspace'

dir = File.dirname(File.expand_path(__FILE__))

configValues = YAML.load_file("#{dir}/puphpet/config.yaml")
data = configValues['vagrantfile-rackspace']

Vagrant.require_version '>= 1.6.0'

Vagrant.configure('2') do |config|
  config.vm.box         = 'dummy'
  config.vm.hostname    = "#{data['vm']['hostname']}"
  config.nfs.functional = false

  config.ssh.private_key_path = "#{data['ssh']['private_key_path']}"
  config.ssh.username         = "#{data['ssh']['username']}"

  config.vm.provider :rackspace do |rs, override|
    override.vm.synced_folder ".", "/vagrant", type: "rsync"

    rs.username           = "#{data['vm']['provider']['rackspace']['username']}"
    rs.api_key            = "#{data['vm']['provider']['rackspace']['api_key']}"
    rs.flavor             = /#{data['vm']['provider']['rackspace']['size']}/
    rs.image              = "#{data['vm']['provider']['rackspace']['image']}"
    rs.rackspace_region   = "#{data['vm']['provider']['rackspace']['region'].downcase}"
    rs.public_key_path    = "#{data['ssh']['public_key_path']}"
    rs.server_name        = "#{data['vm']['provider']['rackspace']['server_name']}"
    override.ssh.username = 'root'
  end

  data['vm']['synced_folder'].each do |i, folder|
    if folder['source'] != '' && folder['target'] != ''
      config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}"
    end
  end

  config.vm.provision 'shell' do |s|
    s.path = 'puphpet/shell/initial-setup.sh'
    s.args = '/vagrant/puphpet'
  end
  config.vm.provision :shell, :path => 'puphpet/shell/install-ruby.sh'
  config.vm.provision :shell, :path => 'puphpet/shell/install-puppet.sh'

  config.vm.provision :puppet do |puppet|
    ssh_username = !data['ssh']['username'].nil? ? data['ssh']['username'] : 'vagrant'
    puppet.facter = {
      'ssh_username'     => "#{ssh_username}",
      'provisioner_type' => ENV['VAGRANT_DEFAULT_PROVIDER'],
      'vm_target_key'    => 'vagrantfile-rackspace',
    }
    puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}"
    puppet.manifest_file  = "#{data['vm']['provision']['puppet']['manifest_file']}"
    puppet.module_path    = "#{data['vm']['provision']['puppet']['module_path']}"

    if !data['vm']['provision']['puppet']['options'].empty?
      puppet.options = data['vm']['provision']['puppet']['options']
    end
  end

  config.vm.provision :shell do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['exec-once', 'exec-always']
  end
  config.vm.provision :shell, run: 'always' do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['startup-once', 'startup-always']
  end
  config.vm.provision :shell, :path => 'puphpet/shell/important-notices.sh'

  if !data['ssh']['host'].nil?
    config.ssh.host = data['ssh']['host']
  end
  if !data['ssh']['port'].nil?
    config.ssh.port = "#{data['ssh']['port']}"
  end
  if !data['ssh']['guest_port'].nil?
    config.ssh.guest_port = data['ssh']['guest_port']
  end
  if !data['ssh']['shell'].nil?
    config.ssh.shell = "#{data['ssh']['shell']}"
  end
  if !data['ssh']['keep_alive'].nil?
    config.ssh.keep_alive = data['ssh']['keep_alive']
  end
  if !data['ssh']['forward_agent'].nil?
    config.ssh.forward_agent = data['ssh']['forward_agent']
  end
  if !data['ssh']['forward_x11'].nil?
    config.ssh.forward_x11 = data['ssh']['forward_x11']
  end

end


require 'yaml'

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'linode'

dir = File.dirname(File.expand_path(__FILE__))

configValues = YAML.load_file("#{dir}/puphpet/config.yaml")
data = configValues['vagrantfile-linode']

Vagrant.require_version '>= 1.6.0'

Vagrant.configure('2') do |config|
  config.vm.box      = 'dummy'
  config.vm.hostname = "#{data['vm']['hostname']}"

  config.ssh.private_key_path = "#{data['ssh']['private_key_path']}"
  config.ssh.username         = "#{data['ssh']['username']}"

  config.vm.provider :linode do |provider|
    provider.token        = "#{data['vm']['provider']['linode']['token']}"
    provider.distribution = "#{data['vm']['provider']['linode']['distribution']}"
    provider.datacenter   = "#{data['vm']['provider']['linode']['datacenter']}"
    provider.plan         = "#{data['vm']['provider']['linode']['plan']}"
    provider.ssh_key_name = "#{data['vm']['provider']['linode']['ssh_key_name']}"
  end

  data['vm']['synced_folder'].each do |i, folder|
    if folder['source'] != '' && folder['target'] != ''
      config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}"
    end
  end

  config.vm.provision 'shell' do |s|
    s.path = 'puphpet/shell/initial-setup.sh'
    s.args = '/vagrant/puphpet'
  end
  config.vm.provision :shell, :path => 'puphpet/shell/install-ruby.sh'
  config.vm.provision :shell, :path => 'puphpet/shell/install-puppet.sh'

  config.vm.provision :puppet do |puppet|
    ssh_username = !data['ssh']['username'].nil? ? data['ssh']['username'] : 'vagrant'
    puppet.facter = {
      'ssh_username'     => "#{ssh_username}",
      'provisioner_type' => ENV['VAGRANT_DEFAULT_PROVIDER'],
      'vm_target_key'    => 'vagrantfile-linode',
    }
    puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}"
    puppet.manifest_file  = "#{data['vm']['provision']['puppet']['manifest_file']}"
    puppet.module_path    = "#{data['vm']['provision']['puppet']['module_path']}"

    if !data['vm']['provision']['puppet']['options'].empty?
      puppet.options = data['vm']['provision']['puppet']['options']
    end
  end

  config.vm.provision :shell do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['exec-once', 'exec-always']
  end
  config.vm.provision :shell, run: 'always' do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['startup-once', 'startup-always']
  end
  config.vm.provision :shell, :path => 'puphpet/shell/important-notices.sh'

  if !data['ssh']['host'].nil?
    config.ssh.host = data['ssh']['host']
  end
  if !data['ssh']['port'].nil?
    config.ssh.port = "#{data['ssh']['port']}"
  end
  if !data['ssh']['guest_port'].nil?
    config.ssh.guest_port = data['ssh']['guest_port']
  end
  if !data['ssh']['shell'].nil?
    config.ssh.shell = "#{data['ssh']['shell']}"
  end
  if !data['ssh']['keep_alive'].nil?
    config.ssh.keep_alive = data['ssh']['keep_alive']
  end
  if !data['ssh']['forward_agent'].nil?
    config.ssh.forward_agent = data['ssh']['forward_agent']
  end
  if !data['ssh']['forward_x11'].nil?
    config.ssh.forward_x11 = data['ssh']['forward_x11']
  end

end

require 'yaml'

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'softlayer'

dir = File.dirname(File.expand_path(__FILE__))

configValues = YAML.load_file("#{dir}/puphpet/config.yaml")
data = configValues['vagrantfile-softlayer']

Vagrant.require_version '>= 1.6.0'

Vagrant.configure('2') do |config|
  config.nfs.functional       = false
  config.ssh.username         = 'root'
  config.ssh.private_key_path = "#{data['ssh']['private_key_path']}"
  config.vm.box               = 'https://github.com/audiolize/vagrant-softlayer/raw/master/dummy.box'

  config.vm.provider :softlayer do |sl|
    sl.hostname           = "#{data['vm']['hostname']}"
    sl.domain             = "#{data['vm']['provider']['softlayer']['domain']}"
    sl.ssh_key            = "#{data['vm']['provider']['softlayer']['ssh_key']}"
    sl.username           = "#{data['vm']['provider']['softlayer']['username']}"
    sl.api_key            = "#{data['vm']['provider']['softlayer']['api_key']}"
    sl.operating_system   = "#{data['vm']['provider']['softlayer']['operating_system']}"
    sl.datacenter         = "#{data['vm']['provider']['softlayer']['datacenter']}"
    sl.max_memory         = data['vm']['provider']['softlayer']['max_memory'].to_i
    sl.start_cpus         = data['vm']['provider']['softlayer']['start_cpus'].to_i
  end

  data['vm']['synced_folder'].each do |i, folder|
    if folder['source'] != '' && folder['target'] != ''
      config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}"
    end
  end

  config.vm.provision 'shell' do |s|
    s.path = 'puphpet/shell/initial-setup.sh'
    s.args = '/vagrant/puphpet'
  end
  config.vm.provision :shell, :path => 'puphpet/shell/install-ruby.sh'
  config.vm.provision :shell, :path => 'puphpet/shell/install-puppet.sh'

  config.vm.provision :puppet do |puppet|
    puppet.facter = {
      'ssh_username'     => 'root',
      'provisioner_type' => ENV['VAGRANT_DEFAULT_PROVIDER'],
      'vm_target_key'    => 'vagrantfile-softlayer',
    }
    puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}"
    puppet.manifest_file  = "#{data['vm']['provision']['puppet']['manifest_file']}"
    puppet.module_path    = "#{data['vm']['provision']['puppet']['module_path']}"

    if !data['vm']['provision']['puppet']['options'].empty?
      puppet.options = data['vm']['provision']['puppet']['options']
    end
  end

  config.vm.provision :shell do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['exec-once', 'exec-always']
  end
  config.vm.provision :shell, run: 'always' do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['startup-once', 'startup-always']
  end
  config.vm.provision :shell, :path => 'puphpet/shell/important-notices.sh'

  if !data['ssh']['host'].nil?
    config.ssh.host = data['ssh']['host']
  end
  if !data['ssh']['port'].nil?
    config.ssh.port = "#{data['ssh']['port']}"
  end
  if !data['ssh']['guest_port'].nil?
    config.ssh.guest_port = data['ssh']['guest_port']
  end
  if !data['ssh']['shell'].nil?
    config.ssh.shell = "#{data['ssh']['shell']}"
  end
  if !data['ssh']['keep_alive'].nil?
    config.ssh.keep_alive = data['ssh']['keep_alive']
  end
  if !data['ssh']['forward_agent'].nil?
    config.ssh.forward_agent = data['ssh']['forward_agent']
  end
  if !data['ssh']['forward_x11'].nil?
    config.ssh.forward_x11 = data['ssh']['forward_x11']
  end

end

require 'yaml'

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'aws'

dir = File.dirname(File.expand_path(__FILE__))

configValues = YAML.load_file("#{dir}/puphpet/config.yaml")
data = configValues['vagrantfile-aws']

Vagrant.require_version '>= 1.6.0'

Vagrant.configure('2') do |config|
  config.vm.box      = 'dummy'
  config.vm.hostname = "#{data['vm']['hostname']}"

  config.vm.provider :aws do |aws, override|
    aws.access_key_id             = "#{data['vm']['provider']['aws']['access_key_id']}"
    aws.secret_access_key         = "#{data['vm']['provider']['aws']['secret_access_key']}"
    aws.keypair_name              = "#{data['vm']['provider']['aws']['keypair_name']}"
    aws.ami                       = "#{data['vm']['provider']['aws']['ami']}"
    aws.instance_type             = "#{data['vm']['provider']['aws']['instance_type']}"
    override.ssh.username         = "#{data['ssh']['username']}"
    override.ssh.private_key_path = "#{data['ssh']['private_key_path']}"
    if !data['vm']['provider']['aws']['region'].nil?
      aws.region                  = "#{data['vm']['provider']['aws']['region']}"
    end

    if !data['vm']['provider']['aws']['security_groups'].nil? && !data['vm']['provider']['aws']['security_groups'].empty?
      aws.security_groups = data['vm']['provider']['aws']['security_groups']
    end

    aws.tags = {}
    data['vm']['provider']['aws']['tags'].each do |key, tag|
      aws.tags.store(:key, tag)
    end
  end

  data['vm']['synced_folder'].each do |i, folder|
    if folder['source'] != '' && folder['target'] != ''
      config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}"
    end
  end

  config.vm.provision 'shell' do |s|
    s.path = 'puphpet/shell/initial-setup.sh'
    s.args = '/vagrant/puphpet'
  end
  config.vm.provision :shell, :path => 'puphpet/shell/install-ruby.sh'
  config.vm.provision :shell, :path => 'puphpet/shell/install-puppet.sh'

  config.vm.provision :puppet do |puppet|
    ssh_username = !data['ssh']['username'].nil? ? data['ssh']['username'] : 'vagrant'
    puppet.facter = {
      'ssh_username'     => "#{ssh_username}",
      'provisioner_type' => ENV['VAGRANT_DEFAULT_PROVIDER'],
      'vm_target_key'    => 'vagrantfile-aws',
    }
    puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}"
    puppet.manifest_file  = "#{data['vm']['provision']['puppet']['manifest_file']}"
    puppet.module_path    = "#{data['vm']['provision']['puppet']['module_path']}"

    if !data['vm']['provision']['puppet']['options'].empty?
      puppet.options = data['vm']['provision']['puppet']['options']
    end
  end

  config.vm.provision :shell do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['exec-once', 'exec-always']
  end
  config.vm.provision :shell, run: 'always' do |s|
    s.path = 'puphpet/shell/execute-files.sh'
    s.args = ['startup-once', 'startup-always']
  end
  config.vm.provision :shell, :path => 'puphpet/shell/important-notices.sh'

  if !data['ssh']['host'].nil?
    config.ssh.host = data['ssh']['host']
  end
  if !data['ssh']['port'].nil?
    config.ssh.port = "#{data['ssh']['port']}"
  end
  if !data['ssh']['guest_port'].nil?
    config.ssh.guest_port = data['ssh']['guest_port']
  end
  if !data['ssh']['shell'].nil?
    config.ssh.shell = "#{data['ssh']['shell']}"
  end
  if !data['ssh']['keep_alive'].nil?
    config.ssh.keep_alive = data['ssh']['keep_alive']
  end
  if !data['ssh']['forward_agent'].nil?
    config.ssh.forward_agent = data['ssh']['forward_agent']
  end
  if !data['ssh']['forward_x11'].nil?
    config.ssh.forward_x11 = data['ssh']['forward_x11']
  end

end
$ vagrant -v
Vagrant 1.6.5
$ virtualbox -h
Oracle VM VirtualBox Manager 4.3.20
(...)
$ vagrant plugin list
vagrant-cachier (1.1.0)
vagrant-hostmanager (1.5.0)
vagrant-login (1.0.1, system)
vagrant-share (1.1.2, system)

Thanks in advance for any help.

@kusmierz

This comment has been minimized.

Copy link

kusmierz commented Dec 9, 2014

@jtreminio Note multiple require 'yaml' above (I've redownloaded Vagrantfile from https://puphpet.com/upload-config after uploaded my config.yaml (attached above)).

@jtreminio

This comment has been minimized.

Copy link
Member

jtreminio commented Dec 9, 2014

ok that clears up what the issue may be.

@jtreminio

This comment has been minimized.

Copy link
Member

jtreminio commented Dec 25, 2014

I am unable to duplicate this issue.

Are you including multiple vagrantfile-* sections in a single yaml file? That's not supported

@kusmierz

This comment has been minimized.

Copy link

kusmierz commented Dec 27, 2014

@jtreminio I know it's unsupported, but those files was generated by https://puphpet.com/ (based on my current (see above) config.yaml).

@kusmierz

This comment has been minimized.

Copy link

kusmierz commented Mar 10, 2015

it has been fixed already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment