Ansible playbook to install Go .deb file

4,557 views
Skip to first unread message

Kief Morris

unread,
Mar 31, 2014, 9:01:17 AM3/31/14
to go...@googlegroups.com
Hi all,

Does anyone have an example of an Ansible playbook that installs Go (TW Go, not the language) 13.4.1 from the .deb file? I've seen it done from the zip, but would like to install it from the .deb if possible.

I've been trying this on a Vagrant box, but, annoyingly, it hangs on the dpkg -i command. It does install it - I can access it from my browser - the ansible task just doesn't return. If I comment out the ansible task, destroy, up, and ssh to the box then run the dpkg command manually, it installs it and returns just fine.

My Ansible task looks like:

- name: download Go
  get_url
: url="{{ go_download }}" "dest=/var/Download/{{ go_package }}"

- name: Install Go
  command
: "dpkg -i go-server /var/Download/{{ go_package }}"



The go_package variable is go-server-13.4.1-18342.deb, and go_download is http://download01.thoughtworks.com/go/13.4.1/ga/go-server-13.4.1-18342.deb. I'm installing this to Ubuntu 12.04

Thanks,
Kief

Tom Duckering

unread,
Mar 31, 2014, 9:18:12 AM3/31/14
to Kief Morris, go...@googlegroups.com
Smells like it's expecting some input or a tty.

Have you been able to automate it's install via dpkg with anything else?


--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kief Morris

unread,
Mar 31, 2014, 10:23:25 AM3/31/14
to Tom Duckering, go...@googlegroups.com
If I comment out the actual dpkg command from ansible, and add a Vagrant shell provisioner to run that command after, it installs without hanging. So it seems to be Ansible-specific.

Aravind SV

unread,
Mar 31, 2014, 3:06:06 PM3/31/14
to Kief Morris, Tom Duckering, go...@googlegroups.com
Someone was recently talking to me about Go not installing when using Ansible. I'll ask that person if he found anything about it.

I don't think the deb package waits for input. It does try and start the server and waits a bit for it to start up. It might be interesting to know whether it got to that point in the installation, when it hangs.

Cheers,
Aravind

Kief Morris

unread,
Apr 1, 2014, 5:20:56 AM4/1/14
to Aravind SV, Tom Duckering, go...@googlegroups.com
On Mon, Mar 31, 2014 at 8:06 PM, Aravind SV <arv...@thoughtworks.com> wrote:
I don't think the deb package waits for input. It does try and start the server and waits a bit for it to start up. It might be interesting to know whether it got to that point in the installation, when it hangs.

No, it doesn't seem like it's waiting for input. It does get to the point of starting it up, Go is accessible from a web browser, and the logs show it's tried to load up pipelines, and generally seems normal.


Tom Scott

unread,
May 12, 2014, 8:18:07 AM5/12/14
to go...@googlegroups.com, Aravind SV, Tom Duckering
I've been playing around with the same playbook and I'm experiencing the same problem. I've finally solved it by using raw (despite recommendations against it). The play below shows the three options I tried: the apt module (as of 1.6), command & raw. I also thought that it was waiting for input but the --force-confold option took care of the prompting I was getting. 

- name: Install Go
# apt: deb=/var/Download/{{ go_package }} dpkg_options='force-confold,force-confdef' state=installed
# command: dpkg --force-confold -i /var/Download/{{ go_package }}
raw: sudo dpkg --force-confold -i /var/Download/{{ go_package }}

My current theory is that it has something to do with the NOHUP in the Go installation which causes SSH to fail to log off (as described here) because it's hanging on to one of the output streams. I suspect that Ansible does something slightly different as if I try to execute the installation with vagrant ssh it works fine and hence the fallback to raw.

vagrant ssh '-c sudo dpkg --force-confold -i /var/Download/go-server-14.1.0-18882.deb' goserver  

It would be great if someone could validate my thinking - does the explanation make sense? Is there anybody with more Ansible fu that can confirm or disprove my theory?

Reply all
Reply to author
Forward
0 new messages