Any idea how to set 'dev_ip_address' for a custom type project?

56 views
Skip to first unread message

Mihail Juganaru

unread,
May 26, 2016, 7:04:54 AM5/26/16
to Otto
Hello guys,

I've been trying to set the IP address for a 'custom' type project in the 'Appfile' through this customization:

application {
  name
= "custom-vagrant"
  type
= "custom"
}

customization
{
  dev_vagrantfile
= "./Vagrantfile"
  dev_ip_address
= "100.71.31.152"
}

In the custom referenced 'Vagrantfile' I've setup the same IP address:

  config.vm.network "private_network", ip: "100.71.31.152"

The problem is that after compiling and running 'otto dev' it returns a different address:

otto dev address
100.110.118.57


After that I ssh to the VM that is a PHP 7 ready Vagrant box (peterrehm/trusty-php7) and open a server with a simple PHP script:

$ php -S 0.0.0.0:4578 index.php
PHP 7.0.5-3+donate.sury.org~trusty+1 Development Server started at Thu May 26 12:56:04 2016
Listening on http://0.0.0.0:4578
Document root is /vagrant
Press Ctrl-C to quit.


The problem is that the otto dev address 100.110.118.57 cannot be accessed from the host OS, I can only use the IP address that I've setup in the custom 'Vagrantfile'.

Why isn't otto displaying my 'dev_ip_address' instead of this random generated one? :) This is pretty confusing...

Thanks,
Mihail

Michael Leow

unread,
May 29, 2016, 1:39:44 PM5/29/16
to Otto
Mihail,

dev_ip_address is a variable that can be used in the Vagrantfile template; NOT a customization.



config.vm.synced_folder '{{ path.working }}', "/vagrant"

The question is; if you are only having a PHP App; why are you doing a custom type project, what are you trying to achieve?

"Custom" app type should be generally avoided (as as per the docs; should only be used to prototype codifying into a plugin) since you pretty much lose most of the benefits of using Otto.

Mihail Juganaru

unread,
May 30, 2016, 7:42:54 AM5/30/16
to Otto
Hello Michael,

Since the 'php_version' customization for 'php' application type is locked to 5.* at the moment I was experimenting different ways to create a VM with PHP 7 support.

I'm not advanced enough with Go programming to create a plugin so I've used a 'custom' application type with a custom Vagrantfile that loads a ready to go PHP 7 box.

Below you have my Appfile which is based on the documentation, from both Index page ( https://www.ottoproject.io/docs/apps/custom/index.html ) and Development page ( https://www.ottoproject.io/docs/apps/custom/dev.html ) for Custom App Type:

application {
  name
= "custom-vagrant"
  type
= "custom"
}


customization
"dev" {
  vagrantfile
= "./Vagrantfile"
}

My custom Vagrantfile has the template customizations like this ( https://www.ottoproject.io/docs/apps/custom/dev.html ):

Vagrant.configure("2") do |config|
 
 
if ENV["OTTO_VAGRANT_LAYER_PATH"]
    config
.vm.clone = ENV["OTTO_VAGRANT_LAYER_PATH"]
 
else
    config
.vm.box = "peterrehm/trusty-php7"
    config
.vm.box_check_update = false
 
end
 

 
# Host only network
  config
.vm.network "private_network", ip: '{{ dev_ip_address }}'

 
 
# Setup a synced folder from our working directory to /vagrant
  config
.vm.synced_folder '{{ path.working }}', "/vagrant",
    owner
: "vagrant", group: "vagrant"
 

 
# Enable SSH agent forwarding so getting private dependencies works
  config
.ssh.forward_agent = true


 
# Load all our fragments here for any dependencies.
 

 
# Use linked clones if possible
  config
.vm.provider "virtualbox" do |p|
    p
.linked_clone = true
 
end
 
 

  config
.vm.provider "virtualbox" do |v|
    v
.memory = 1024
 
end

end


I compile this, then running 'otto dev' fails:

Error building dev environment: Otto can't build a development environment for this because the
"vagrant" setting hasn't been set in the "dev" or "dev-dep" customization.

For the "custom" application type, customizations must be used to
tell Otto what to do. For the dev command, Otto requires either
the "dev" or "dev-dep" customization to be set with the "vagrant" setting.
The "vagrant" setting depends on which customization is being set. Please
refer to the documentation for more details.

Example:

    customization "dev" {
        vagrantfile = "path/to/Vagrantfile"
    }


This is a bug because the syntax was changed and the documentation is not updated... https://github.com/hashicorp/otto/issues/106#issuecomment-173318751

So I update my Appfile with the new syntax like this:


application {
  name
= "custom-vagrant"
  type
= "custom"
}

customization
{
  dev_vagrantfile
= "./Vagrantfile"
}

Then I clear the compiled files "rm -rf .otto*", recompile with "otto compile" and run "otto dev" again. It fails again:

vm:
* The host path of the shared folder is missing: {{ path.working }}

Is there anything that I'm doing wrong?

Thanks,
Mihail

P.S.: I'm the guy from Twitter who DM you about your latest Otto builds :)

Michael Leow

unread,
May 31, 2016, 12:10:37 AM5/31/16
to Otto
@Mihail,

If you are just wanting to try out PHP 7.0; that is incorporated into the current v0.2 code already; so specify "7.0" as the customization. See source code below:


# php_install installs an arbitrary PHP version given in the argument
php_install() {
   
local version="$1"
   
case $version in
    7.0)
        php_install_prepare
        php_install_7_0
       
;;
    5.6)
        php_install_prepare
        php_install_5_6
       
;;
    5.5)
        php_install_prepare
        php_install_5_5
       
;;
    *)
        echo
"Unknown PHP version: ${version}"
       
exit 1
        ;;
    esac
}

PS: Do try out the compiled test binaries link for issue #442 (which has the bento/ubuntu14.04); and report back if it works for your latest PHP 7.0 (esp. if it solves the broken Docker version).

Cheers!
Michael Leow

Mihail Juganaru

unread,
May 31, 2016, 11:06:52 AM5/31/16
to Otto
Hi!

I've almost gone insane today after compiling the 'Appfile' several times both on Windows and Linux with 'php_version = 7.0' customization and your latest binaries. I've discovered another wrong thing in the Otto documentation!

In the documentation we have:

application {
 name
= "otto-test"
 type
= "php"
}

customization
"php" {
 php_version
= "7.0"
}

But the correct way to declare this customization is:

application {
 name
= "otto-test"
 type
= "php"
}

customization
{
 php_version
= "7.0"
}


So after this change I've managed to compile the application, but PHP 7 is not installed when running 'otto dev':

==> default: [otto] Installing PHP Version 7.0
==> default: ERROR at /otto/scriptpacks/PHP/STDLIB/execute.sh:5; Last logs:
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:43 precise64 otto: Hit http://us.archive.ubuntu.com precise/multiverse Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:43 precise64 otto: Hit http://us.archive.ubuntu.com precise/restricted Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:43 precise64 otto: Hit http://us.archive.ubuntu.com precise/universe Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:44 precise64 otto: Hit http://us.archive.ubuntu.com precise-updates/main Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:44 precise64 otto: Hit http://us.archive.ubuntu.com precise-updates/multiverse Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:44 precise64 otto: Hit http://us.archive.ubuntu.com precise-updates/restricted Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:44 precise64 otto: Hit http://us.archive.ubuntu.com precise-updates/universe Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:44 precise64 otto: Hit http://us.archive.ubuntu.com precise-backports/main Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:44 precise64 otto: Hit http://us.archive.ubuntu.com precise-backports/multiverse Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:44 precise64 otto: Hit http://us.archive.ubuntu.com precise-backports/restricted Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:44 precise64 otto: Hit http://us.archive.ubuntu.com precise-backports/universe Translation-en
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:52 precise64 otto: Fetched 5,319 kB in 22s (241 kB/s)
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:52 precise64 otto: W: Failed to fetch http://ppa.launchpad.net/ondrej/php-7.0/ubuntu/dists/precise/main/source/Sources  404  Not Found
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:52 precise64 otto:
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:52 precise64 otto: W: Failed to fetch http://ppa.launchpad.net/ondrej/php-7.0/ubuntu/dists/precise/main/binary-amd64/Packages  404  Not Found
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:52 precise64 otto:
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:52 precise64 otto: W: Failed to fetch http://ppa.launchpad.net/ondrej/php-7.0/ubuntu/dists/precise/main/binary-i386/Packages  404  Not Found
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:52 precise64 otto:
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:52 precise64 otto: E: Some index files failed to download. They have been ignored, or old ones used instead.
==> default: May 31 14:29:53 precise64 otto: May 31 14:29:52 precise64 otto: ERROR at /otto/scriptpacks/PHP/PHP/install.sh:56; Last logs:
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
Error building dev environment: Error building dev environment layers: Error executing Vagrant: exit status 1

The error messages from Vagrant are usually very informative.
Please read it carefully and fix any issues it mentions. If
the message isn't clear, please report this to the Otto project.

Looks like there is no PHP 7 package for Ubuntu Precise, also 'php-7.0' should be 'php-zts':

http://ppa.launchpad.net/ondrej/php-zts/ubuntu/dists/

This script is definitely wrong: https://github.com/hashicorp/otto/blob/master/builtin/scriptpack/php/data/install.sh

I've also replied to your Gist regarding the other thing, still no luck with compiling a 'bento/ubuntu-14.04' box.

I don't use Docker, when I have time I will give it a go.

Thanks,
Mihail

Blotto

unread,
May 31, 2016, 11:20:01 AM5/31/16
to Otto
After your 'otto compile' run:
find ./ -name "Vagrantfile" -exec sed -i "s|hashicorp/precise64|bento/ubuntu-14.04|" {} \;

I would really like to see an update to the bento/ubuntu-14.04 box.  Precise is broken in so many ways.  Been trying to see if we can get a new Otto release soon because as it stands I'm having a hard time convincing my employer that we should use it.

Mihail Juganaru

unread,
May 31, 2016, 11:48:41 AM5/31/16
to Otto
Hi Blotto!

Thanks for the reply! I know about this hack with replacing the config.vm.box value in the compiled Vagrantfile(s).  :)

Michael L. here in this thread made some new builds with this pull request that are supposed to work without this manual replace. They are available here if you would also like to test them, I didn't have success.

I think that the guys from HashiCorp are really busy with the other tools that Otto is built on (judging by their latest commits :P), so the release cycle is unknown at this moment. I wouldn't use this in production until version 1.0... :D

All the best,
Mihail

Michael Leow

unread,
Jun 1, 2016, 4:55:53 AM6/1/16
to Otto
@Mahail,

Looks like the repo has comsolidated (since Otto v0.2) to https://launchpad.net/~ondrej/+archive/ubuntu/php


The available variants: php5.5, php5.6, php7.0

When I get some time later; I'll apply a patch and recompile for you to try.

Adam Mulvany

unread,
Jun 1, 2016, 1:14:59 PM6/1/16
to otto...@googlegroups.com
Thanks Mihael for the advice and thanks Michael for the patch/recompile.

This is a very exciting project which I feel has great potential so great to see it's still being supported.

Kind regards,
Adam/Blotto

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/otto/issues
IRC: #otto-tool on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Otto" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/otto-tool/rSiQtdKSYoI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to otto-tool+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/otto-tool/2700d4f8-3db2-45da-92a4-06a916696faf%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages