behemphi / ops-hire-project

Contrast Operations Hire Project
0 stars 0 forks source link

`vagrant up` leads to syntax error out of the box #2

Closed behemphi closed 7 years ago

behemphi commented 7 years ago

After installing Ansible, issuing vagrant up leads to the following error:

ERROR! Syntax Error while loading YAML.

The error appears to have been in '/Users/behemphi/contrast-security/ops-hire-project/roles/base/tasks/main.yml': line 8, column 11, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  with_items:
     - git
          ^ here

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

Full command output is below:

behemphi:~/contrast-security/ops-hire-project 12:58:10 > vagrant up
Bringing machine 'database' up with 'virtualbox' provider...
Bringing machine 'appserver' up with 'virtualbox' provider...
==> database: Importing base box 'ubuntu/trusty64'...
==> database: Matching MAC address for NAT networking...
==> database: Checking if box 'ubuntu/trusty64' is up to date...
==> database: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> database: have version '20160621.0.0'. The latest is version '20170313.0.7'. Run
==> database: `vagrant box update` to update.
==> database: Setting the name of the VM: ops-hire-project_database_1490464710347_74973
==> database: Clearing any previously set forwarded ports...
==> database: Clearing any previously set network interfaces...
==> database: Preparing network interfaces based on configuration...
    database: Adapter 1: nat
    database: Adapter 2: hostonly
==> database: Forwarding ports...
    database: 22 (guest) => 2222 (host) (adapter 1)
==> database: Running 'pre-boot' VM customizations...
==> database: Booting VM...
==> database: Waiting for machine to boot. This may take a few minutes...
    database: SSH address: 127.0.0.1:2222
    database: SSH username: vagrant
    database: SSH auth method: private key
    database: 
    database: Vagrant insecure key detected. Vagrant will automatically replace
    database: this with a newly generated keypair for better security.
    database: 
    database: Inserting generated public key within guest...
    database: Removing insecure key from the guest if it's present...
    database: Key inserted! Disconnecting and reconnecting using new SSH key...
==> database: Machine booted and ready!
==> database: Checking for guest additions in VM...
    database: The guest additions on this VM do not match the installed version of
    database: VirtualBox! In most cases this is fine, but in rare cases it can
    database: prevent things such as shared folders from working properly. If you see
    database: shared folder errors, please make sure the guest additions within the
    database: virtual machine match the version of VirtualBox you have installed on
    database: your host and reload your VM.
    database: 
    database: Guest Additions Version: 4.3.36
    database: VirtualBox Version: 5.0
==> database: Setting hostname...
==> database: Configuring and enabling network interfaces...
==> database: Mounting shared folders...
    database: /vagrant => /Users/behemphi/contrast-security/ops-hire-project
==> database: Running provisioner: ansible...
    database: Running ansible-playbook...
ERROR! Syntax Error while loading YAML.

The error appears to have been in '/Users/behemphi/contrast-security/ops-hire-project/roles/base/tasks/main.yml': line 8, column 11, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  with_items:
     - git
          ^ here

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
dhafley commented 7 years ago

What version of ansible are you running? How did you install ansible?

I see:

$ ansible --version
ansible 2.2.1.0
  config file = /Users/davidhafley/.ansible.cfg
  configured module search path = Default w/o overrides

That results in output:

$ vagrant up
Bringing machine 'database' up with 'virtualbox' provider...
Bringing machine 'appserver' up with 'virtualbox' provider...
==> database: Checking if box 'ubuntu/trusty64' is up to date...
==> database: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> database: have version '20160311.0.0'. The latest is version '20170313.0.7'. Run
==> database: `vagrant box update` to update.
==> database: Clearing any previously set forwarded ports...
==> database: Clearing any previously set network interfaces...
==> database: Preparing network interfaces based on configuration...
    database: Adapter 1: nat
    database: Adapter 2: hostonly
==> database: Forwarding ports...
    database: 22 (guest) => 2222 (host) (adapter 1)
==> database: Running 'pre-boot' VM customizations...
==> database: Booting VM...
==> database: Waiting for machine to boot. This may take a few minutes...
    database: SSH address: 127.0.0.1:2222
    database: SSH username: vagrant
    database: SSH auth method: private key
==> database: Machine booted and ready!
==> database: Checking for guest additions in VM...
    database: The guest additions on this VM do not match the installed version of
    database: VirtualBox! In most cases this is fine, but in rare cases it can
    database: prevent things such as shared folders from working properly. If you see
    database: shared folder errors, please make sure the guest additions within the
    database: virtual machine match the version of VirtualBox you have installed on
    database: your host and reload your VM.
    database:
    database: Guest Additions Version: 4.3.36
    database: VirtualBox Version: 5.0
==> database: Setting hostname...
==> database: Configuring and enabling network interfaces...
==> database: Mounting shared folders...
    database: /vagrant => /Users/davidhafley/code/dhafley-github/ops-hire-project
==> database: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> database: flag to force provisioning. Provisioners marked to run always will still run.
==> appserver: Checking if box 'ubuntu/trusty64' is up to date...
==> appserver: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> appserver: have version '20160311.0.0'. The latest is version '20170313.0.7'. Run
==> appserver: `vagrant box update` to update.
==> appserver: Fixed port collision for 22 => 2222. Now on port 2200.
==> appserver: Clearing any previously set network interfaces...
==> appserver: Preparing network interfaces based on configuration...
    appserver: Adapter 1: nat
    appserver: Adapter 2: hostonly
==> appserver: Forwarding ports...
    appserver: 80 (guest) => 8080 (host) (adapter 1)
    appserver: 22 (guest) => 2200 (host) (adapter 1)
==> appserver: Running 'pre-boot' VM customizations...
==> appserver: Booting VM...
==> appserver: Waiting for machine to boot. This may take a few minutes...
    appserver: SSH address: 127.0.0.1:2200
    appserver: SSH username: vagrant
    appserver: SSH auth method: private key
    appserver:
    appserver: Vagrant insecure key detected. Vagrant will automatically replace
    appserver: this with a newly generated keypair for better security.
    appserver:
    appserver: Inserting generated public key within guest...
    appserver: Removing insecure key from the guest if it's present...
    appserver: Key inserted! Disconnecting and reconnecting using new SSH key...
==> appserver: Machine booted and ready!
==> appserver: Checking for guest additions in VM...
    appserver: The guest additions on this VM do not match the installed version of
    appserver: VirtualBox! In most cases this is fine, but in rare cases it can
    appserver: prevent things such as shared folders from working properly. If you see
    appserver: shared folder errors, please make sure the guest additions within the
    appserver: virtual machine match the version of VirtualBox you have installed on
    appserver: your host and reload your VM.
    appserver:
    appserver: Guest Additions Version: 4.3.36
    appserver: VirtualBox Version: 5.0
==> appserver: Setting hostname...
==> appserver: Configuring and enabling network interfaces...
==> appserver: Mounting shared folders...
    appserver: /vagrant => /Users/davidhafley/code/dhafley-github/ops-hire-project
==> appserver: Running provisioner: ansible...
    appserver: Running ansible-playbook...
 ____________
< PLAY [all] >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

 ______________
< TASK [setup] >
 --------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [appserver]
 _____________________________________
< TASK [base : Install base packages] >
 -------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver] => (item=[u'git', u'mysql-client'])
 __________________
< PLAY [appserver] >
 ------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

 ______________
< TASK [setup] >
 --------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [appserver]
 ________________________________________
< TASK [apache : Install apache via apt] >
 ----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver] => (item=[u'apache2', u'libapache2-mod-auth-mysql', u'php5-mysql', u'libapache2-mod-php5'])
 ___________________________________________
< TASK [apache : Set default apache config] >
 -------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver]
 _______________________________________
< TASK [webapp : Remove html directory] >
 ---------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver]
 __________________________________________
< TASK [webapp : Checkout the source code] >
 ------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver]
 _________________________________
< TASK [webapp : Create database] >
 ---------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver]
 _________________________________________
< TASK [webapp : Load application schema] >
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver]
 _________________________________
< TASK [webapp : Create database] >
 ---------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver]
 ________________________________
< TASK [webapp : Setup dbconfig] >
 --------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver]
 ____________________________________________
< RUNNING HANDLER [apache : restart apache2] >
 --------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [appserver]
 ____________
< PLAY RECAP >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

appserver                  : ok=12   changed=10   unreachable=0    failed=0
behemphi commented 7 years ago

To answer the version question:

behemphi:~/contrast-security/ops-hire-project 14:11:37 > ansible --version
ansible 2.2.1.0
  config file = 
  configured module search path = Default w/o overrides

Still mucking about learning Ansible so the config file = is bugging me but is not the problem.

The problem was errant white space at the end of that line \<grumble>YAML\</grumble>. Pull request to the root project coming to demonstrate ability to work in a PR driven environment.

behemphi commented 7 years ago

Pull request left for Contrast to remove offending whitespace.