local_action using remote file content

Hi there,

It’s my intention to write a bitbucket module for Ansible.

The use case is :

Create a local VM using vagrant, provisioned by Ansible.

Using Ansible:

1 Generate a SSH key-pair on that machine.

2 Take the freshly generated Public Key and load it into my Bitbucket account, using the bitbucket-api python module.

3 Check out a bunch of projects that I want R/W access to from within the VM.

Then I vagrant ssh into that box, and profit!

I’ve got most of the pieces worked out, but have a couple of questions regarding approach.

I’d like to create a proper Ansible module to handle Bitbucket but for now I’d like to just create a quick script.

I believe local_action is the syntax to use for running commands on my local machine.

Now, I could fetch the ~/.ssh/id_pub.rsa file from the remote VM, and store it on my hard drive somewhere like /tmp/vm.id_pub.rsa,
but ideally I’d like to either pipe it into the script I’m going to write or supply it as a quoted command line argument.

Can this be done (taking the entire contents of a remote file and storing it into a variable) ?

Bryan

Seeing you said “module”, why is the hg module not sufficient for talking to bitbucket?

Not for performing VCS tasks but for talking directly to the bitbucket rest API.

http://restbrowser.bitbucket.org

In order to add the ssh keys from the freshly created VM instance.

POST https://bitbucket.org/api/1.0/users/{accountname}/ssh-keys/

did you write the module?

btw, for cloning it should be enough to support deploy keys.