# local\_action using remote file content

**URL:** <https://forum.ansible.com/t/local-action-using-remote-file-content/14243>\
**Category:** Ansible Project\
**Created:** [December 31, 2013, 2:35pm UTC](https://forum.ansible.com/t/local-action-using-remote-file-content/14243 "2013-12-31T14:35:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryan\_hunt1](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bryan\_hunt1](https://forum.ansible.com/u/bryan_hunt1)\
**Post date:** [December 31, 2013, 2:35pm UTC](https://forum.ansible.com/t/local-action-using-remote-file-content/14243/1 "2013-12-31T14:35:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 31, 2013, 3:02pm UTC](https://forum.ansible.com/t/local-action-using-remote-file-content/14243/2 "2013-12-31T15:02:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bryan\_hunt1](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bryan\_hunt1](https://forum.ansible.com/u/bryan_hunt1)\
**Post date:** [December 31, 2013, 3:09pm UTC](https://forum.ansible.com/t/local-action-using-remote-file-content/14243/3 "2013-12-31T15:09:13Z")

</div>

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

[http://restbrowser.bitbucket.org](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/](https://bitbucket.org/api/1.0/users/%7Baccountname%7D/ssh-keys/)

---

<div class="post-metadata">

**Author:** ![Capi\_Etheriel](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Capi\_Etheriel](https://forum.ansible.com/u/Capi_Etheriel)\
**Post date:** [January 12, 2015, 4:48pm UTC](https://forum.ansible.com/t/local-action-using-remote-file-content/14243/4 "2015-01-12T16:48:47Z")

</div>

did you write the module?

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