Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

vagrant-was: unable to run aws without getting default puphpet page back #574

Open
rasha-hantash opened this issue Jul 27, 2020 · 2 comments

Comments

@rasha-hantash
Copy link

rasha-hantash commented Jul 27, 2020

Able to deploy an ec2 instance onto aws but the public ip gives me back the default PuPHPet page. I am still unable to get to my host page www.bxs.test . I consistently get back a default puphpet page or this :
Screen Shot 2020-07-30 at 3 12 37 PM

Vagrantfile-aws


ENV['VAGRANT_DEFAULT_PROVIDER'] = 'aws'

provider = data['vm']['provider']['aws']
machines = !provider['machines'].empty? ? provider['machines'] : { }

machines.each do |i, machine|
  config.vm.define "#{machine['id']}" do |machine_id|
    machine_id.vm.box         = 'dummy'
    machine_id.vm.hostname    = "#{machine['hostname']}"
    machine_id.nfs.functional = false

    machine_id.vm.provider :aws do |aws, override|
      aws.access_key_id             = "#{provider['access_key_id']}"
      aws.secret_access_key         = "#{provider['secret_access_key']}"
      aws.keypair_name              = "#{machine['keypair_name']}"
      override.ssh.private_key_path = "#{machine['private_key_path']}"
      override.ssh.username         = "#{machine['ssh_username']}"
      aws.region                    = "#{machine['region']}"
      aws.instance_type             = "#{machine['instance_type']}"
      aws.ami                       = "#{machine['ami']}"
      
      if machine['subnet_id'].to_s != ''
        aws.subnet_id               = "#{machine['subnet_id']}"
      end
      if machine['elastic_ip'].to_s != ''
        aws.elastic_ip              = "#{machine['elastic_ip']}"
      end
      if !machine['security_groups'].empty?
        aws.security_groups = machine['security_groups']
      end

      aws.tags = {}
      if machine.key?('tags')
        machine['tags'].each do |key, tag|
          aws.tags.store(key, tag)
        end
      end
    end

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

    machine_id.vm.provision 'shell' do |s|
      s.path = 'puphpet/shell/initial-setup.sh'
    end
    machine_id.vm.provision :shell,
      :inline => 'chmod +x /opt/puphpet/standalone-puppet.sh'
    machine_id.vm.provision 'shell' do |s|
      s.path = 'puphpet/shell/install-puppet.sh'
    end
    machine_id.vm.provision :shell do |s|
      s.path = 'puphpet/shell/execute-files.sh'
      s.args = ['exec-preprovision']
    end

    machine_id.vm.provision :puppet do |puppet|
      ssh_username = !machine['ssh_username'].nil? ? machine['ssh_username'] : 'vagrant'
      puppet.facter = {
        'fqdn'             => "#{machine_id.vm.hostname}",
        'ssh_username'     => "#{ssh_username}",
        'provisioner_type' => ENV['VAGRANT_DEFAULT_PROVIDER'],
      }
      puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}"
      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

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

    machine_id.vm.provision :shell, privileged: false do |s|
      s.path = 'puphpet/shell/execute-files.sh'
      s.args = ['exec-once-unprivileged', 'exec-always-unprivileged']
    end
    machine_id.vm.provision :shell, run: 'always', privileged: false do |s|
      s.path = 'puphpet/shell/execute-files.sh'
      s.args = ['startup-once-unprivileged', 'startup-always-unprivileged']
    end

    machine_id.vm.provision :shell, privileged: false do |s|
      s.path = 'puphpet/shell/important-notices.sh'
    end

    if !data['ssh']['port'].nil? && data['ssh']['port'].to_bool
      machine_id.ssh.port = "#{data['ssh']['port']}"
    end
    if !data['ssh']['shell'].nil?
      machine_id.ssh.shell = "#{data['ssh']['shell']}"
    end
  end
end

config-aws.yaml

vagrantfile:
    target: aws
    vm:
        provider:
            aws:
                access_key_id: -
                secret_access_key: -
                machines:
                    machine1:
                        id: bxs.test
                        hostname: bxs.test
                        keypair_name: 'rasha'
                        private_key_path: -
                        region: us-east-1
                        instance_type: t2.micro
                        ami: ami-0b2a843fbb55d98be 
                        ssh_username: ubuntu
                        security_groups:
                            - vagrant-east1
                        network:
                            private_network: -
                            forwarded_port:
                                port1:
                                    host: '7651'
                                    guest: '22'
                        memory: '1024'
                        cpus: '1'
        provision:
            puppet:
                manifests_path: puphpet/puppet/manifests
                module_path: puphpet/puppet/modules
                      # puphpet/puppet/manifests
                options:
                    - '--verbose'
                    - '--hiera_config /opt/puphpet/puppet/hiera.yaml'
        synced_folder:
            folder1:
                owner: www-data
                group: www-data
                source: ./
                target: /var/www
                sync_type: default
                smb:
                    smb_host: ''
                    smb_username: ''
                    smb_password: ''
                    mount_options:
                        dir_mode: '0777'
                        file_mode: '0666'
                rsync:
                    args:
                        - '--verbose'
                        - '--archive'
                        - '-z'
                    exclude:
                        - .vagrant/
                        - .git/
                    auto: 'true'
        usable_port_range:
            start: 10200
            stop: 10500
        post_up_message: ''
    ssh:
        host: 'false'
        port: 'false'
        private_key_path: 'false'
        username: vagrant
        guest_port: 'false'
        keep_alive: '1'
        forward_agent: 'true'
        forward_x11: 'true'
        shell: 'bash -l'
        insert_key: 'false'
    vagrant:
        host: detect
    proxy:
        http: ''
        https: ''
        ftp: ''
        no_proxy: ''
server:
    install: '1'
    packages:
        - bash-completion
        - htop
        - vim
        - zip
users_groups:
    install: '1'
    groups: {  }
    users: {  }
locale:
    install: '1'
    settings:
        default_locale: en_US.UTF-8
        locales:
            - en_US.UTF-8
        timezone: America/New_York
firewall:
    install: '1'
    rules:
        rule_h3j:
            port:
                - '27017'
                - '8025'
                - '11300'
            priority: '100'
            proto: tcp
            action: accept
resolv:
    install: '1'
    nameservers:
        - 8.8.8.8
        - 8.8.4.4
    domainname: ''
    searchpath: {  }
cron:
    install: '1'
    jobs: {  }
nginx:
    install: '0'
    settings:
        version: present
        default_vhost: 1
        proxy_buffers: '4 256k'
        proxy_buffer_size: 128k
        proxy_connect_timeout: 600s
        proxy_send_timeout: 600s
        proxy_read_timeout: 600s
        names_hash_bucket_size: 128
    upstreams: {  }
    vhosts:
        vhost1:
            server_name: awesome.test
            server_aliases:
                - www.awesome.test
            www_root: /var/www/awesome
            listen_port: '80'
            client_max_body_size: 1m
            ssl: '0'
            locations:
                php_html:
                    www_root: /var/www/awesome
                    location: /
                    autoindex: 'off'
                    internal: 'false'
                    index_files:
                        - index.html
                        - index.php
                    try_files:
                        - $uri
                        - $uri/
                        - /index.php$is_args$args
                php_php:
                    www_root: /var/www/awesome
                    location: '~ \.php$'
                    autoindex: 'off'
                    internal: 'false'
                    index_files:
                        - index.php
                    try_files:
                        - $uri
                        - $uri/
                    set:
                        - '$path_info $fastcgi_path_info'
                    fastcgi: '127.0.0.1:9000'
                    fastcgi_index: index.php
                    fastcgi_split_path: '^(.+?\.php)(/.*)$'
                    fast_cgi_params_extra:
                        - 'SCRIPT_FILENAME $document_root$fastcgi_script_name'
    proxies: {  }
apache:
    install: '1'
    settings:
        version: 2.4
        user: www-data
        group: www-data
        default_vhost: true
        manage_user: false
        manage_group: false
        sendfile: 0
    modules:
        - deflate
        - headers
        - proxy_fcgi
        - rewrite
    vhosts:
        vhost1:
            servername: bxs.test
            serveraliases:
                - www.bxs.test
            docroot: /var/www/public
            port: '80'
            setenvif:
                - 'Authorization "(.*)" HTTP_AUTHORIZATION=$1'
            ssl: '0'
            ssl_cert: LETSENCRYPT
            ssl_key: LETSENCRYPT
            ssl_chain: LETSENCRYPT
            ssl_certs_dir: LETSENCRYPT
            ssl_protocol: ''
            ssl_cipher: ''
            directories:
                php_html:
                    provider: directory
                    path: /var/www/public
                    directoryindex: 'index.php index.html'
                    options:
                        - Indexes
                        - FollowSymlinks
                        - MultiViews
                    allow_override:
                        - All
                    require:
                        - 'all granted'
                php_php:
                    provider: filesmatch
                    path: \.php$
                    sethandler: 'proxy:fcgi://127.0.0.1:9000'
        vhost_ehx:
            servername: saltaire-citizens.test
            serveraliases:
                - www.saltaire-citizens.test
            docroot: /var/www/public
            port: '443'
            setenvif:
                - 'Authorization "(.*)" HTTP_AUTHORIZATION=$1'
            ssl: '1'
            ssl_cert: ''
            ssl_key: ''
            ssl_chain: ''
            ssl_certs_dir: ''
            ssl_protocol: ''
            ssl_cipher: ''
            directories:
                php_html_EMQ:
                    provider: directory
                    path: /var/www/public
                    directoryindex: 'index.php index.html'
                    options:
                        - Indexes
                        - FollowSymlinks
                        - MultiViews
                    allow_override:
                        - All
                    require:
                        - 'all granted'
                php_php_EMQ:
                    provider: filesmatch
                    path: \.php$
                    sethandler: 'proxy:fcgi://127.0.0.1:9000'
letsencrypt:
    install: '1'
    settings:
        email: ''
        webserver_service: ''
    domains: {  }
php:
    install: '1'
    settings:
        version: '7.2'
    modules:
        php:
            - cli
            - intl
            - xml
            - curl
            - gd
            - json
            - mbstring
        pear: {  }
        pecl: {  }
    ini:
        display_errors: 'On'
        error_reporting: '-1'
        session.save_path: /var/lib/php/session
        date.timezone: America/New_York
        post_max_size: 200MB
        max_file_uploads: '20'
        upload_max_filesize: 200MB
        max_input_time: '300'
        max_execution_time: '300'
    fpm_ini:
        error_log: /var/log/php-fpm.log
    fpm_pools:
        pool1:
            ini:
              prefix: www
              listen: '127.0.0.1:9000'
              security.limit_extensions: .php7
              user: www-data
              group: www-data
    composer: '1'
    composer_home: ''
xdebug:
    install: '1'
    settings:
        xdebug.default_enable: '1'
        xdebug.remote_autostart: '0'
        xdebug.remote_connect_back: '1'
        xdebug.remote_enable: '1'
        xdebug.remote_handler: dbgp
        xdebug.remote_port: '9001'
        xdebug.remote_host: 192.168.56.1
        xdebug.idekey: VAGRANT
        xdebug.profiler_output_dir: /var/www/xdebug
        xdebug.remote_log: /var/www/xdebug/xdebug.log
        xdebug.profiler_enable_trigger: '1'
        trace_enable_trigger: '1'
blackfire:
    install: '0'
    settings:
        server_id: ''
        server_token: ''
        agent:
            http_proxy: ''
            https_proxy: ''
            log_file: stderr
            log_level: '1'
        php:
            agent_timeout: '0.25'
            log_file: ''
            log_level: '1'
wpcli:
    install: '0'
drush:
    install: '0'
    version: 8.0.5
ruby:
    install: '1'
    versions:
        ruby1:
            default: '1'
            bundler: '1'
            version: '2.4'
            gems:
                - deep_merge@1.2.1
                - activesupport@5.1.4
                - vine@0.4
python:
    install: '1'
    packages: {  }
    versions: {  }
nodejs:
    install: '1'
    settings:
        version: '8'
    npm_packages:
        - bower
        - grunt
        - grunt-concurrent
        - grunt-contrib-clean
        - grunt-contrib-concat
        - grunt-contrib-copy
        - grunt-contrib-cssmin
        - grunt-contrib-sass
        - grunt-contrib-uglify
        - grunt-contrib-watch
        - grunt-exec
        - grunt-modernizr
        - grunt-rsync
        - grunt-show-config
        - grunt-ssh
        - grunt-string-replace
        - jit-grunt
        - load-grunt-config
mariadb:
    install: '0'
    settings:
        version: '10.1'
        root_password: -
        override_options: {  }
    users:
        user1:
            name: -
            password: -
    databases:
        database1:
            name: dbname
            collate: utf8_general_ci
            sql: ''
    grants:
        grant1:
            user: -
            table: '*.*'
            privileges:
                - ALL
mysql:
    install: '0'
    settings:
        version: '5.7'
        root_password: -
        override_options: {  }
    users:
        user1:
            name: -
            password: -
    databases:
        database1:
            name: dbname
            collate: utf8_general_ci
            sql: ''
    grants:
        grant1:
            user: -
            table: '*.*'
            privileges:
                - ALL
postgresql:
    install: '0'
    settings:
        global:
            encoding: UTF8
            version: '9.6'
        server:
            postgres_password: -
    databases:
        database1:
            dbname: -
            owner: -
    users:
        user1:
            username: x
            password: x
            superuser: '1'
    grants:
        grant1:
            role: dbuser
            db: dbname
            privilege:
                - ALL
mongodb:
    install: '0'
    settings:
        bind_ip: 127.0.0.1
        port: '27017'
    globals:
        version: 3.6.2
    databases:
        database1:
            name: dbname
            user: dbuser
            password: '123'
redis:
    install: '0'
    settings:
        port: '6379'
sqlite:
    install: '0'
    databases:
        database1:
            name: dbname
            owner: www-data
            group: www-data
            sql_file: ''
mailhog:
    install: '1'
    settings:
        smtp_ip: 0.0.0.0
        smtp_port: 1025
        http_ip: 0.0.0.0
        http_port: '8025'
        path: /usr/local/bin/mailhog
beanstalkd:
    install: '1'
    settings:
        listenaddress: 0.0.0.0
        listenport: '11300'
        maxjobsize: '65535'
        maxconnections: '1024'
        binlogdir: /var/lib/beanstalkd/binlog
        binlogfsync: null
        binlogsize: '10485760'
    beanstalk_console: '1'
rabbitmq:
    install: '0'
    settings:
        port: '5672'
    users:
        user1:
            admin: '1'
            name: x
            password: x
            tags:
                - admin
    vhosts: {  }
    plugins: {  }
elastic_search:
    install: '0'
    settings:
        version: 6.1.2
        java_install: true
    instances:
        instance1:
            name: es-01
            jvm_options:
                - '-Xms2G'
                - '-Xmx2G'
@matschaffer
Copy link

I'm fairly certain those unable to resolve host ip-xxx-xx-xx-xxx messages are a result of not having a fix like devopsgroup-io/vagrant-hostmanager#86 (comment) in Vagrantfile-aws so that vagrant-hostmanager knows to use the EC2 external IP for your local /etc/hosts entry.

@rasha-hantash rasha-hantash changed the title vagrant-was: unable to resolve host ip-xxx-xx-xx-xxx (using puphpet) vagrant-was: unable to run aws without getting default puphpet page back Jul 31, 2020
@rasha-hantash
Copy link
Author

I'm fairly certain those unable to resolve host ip-xxx-xx-xx-xxx messages are a result of not having a fix like devopsgroup-io/vagrant-hostmanager#86 (comment) in Vagrantfile-aws so that vagrant-hostmanager knows to use the EC2 external IP for your local /etc/hosts entry.

For whatever reason that didn't resolve my issue - I probably implemented it incorrectly.
I was able to resolve it by running vagrant up --no-provision and then vagrant ssh to modify the etc/hosts file by adding 127.01.1 ip-xx-xx-xx and this exiting the box and running vagrant provision

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants