Ask Your Question

source openrc with ansible

asked 2016-06-09 07:05:56 -0500

anonymous user


updated 2016-06-09 09:11:02 -0500

Hi All,

I have tried to create cinder volume on my devstack (VM2) from ansbile (VM1), on devstack did source openrc, while trying to create cinder volume from ansible, by the following command

ansible devstack -m command -a 'source /home/test/devstack/openrc'

Also Tried with Shell command as well

ansible devstack -m shell -a 'source /home/test/devstack/openrc'

Got output as below

devstack | FAILED | rc=2 >> [Errno 2] No such file or directory

Play book also tried :

  • name: source bashrc sudo: no
    shell: source /home/test/devstack/openrc args: executable: /bin/bash

But no luck,while running same "source /home/test/devstack/openrc" on devstack is working fine, may i know how to use ansible to source openrc


edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2016-06-10 02:15:09 -0500

ansible -m shell -a ". ~/ ; cinder list" testserver, it will work

edit flag offensive delete link more

answered 2016-06-09 09:57:43 -0500

updated 2016-06-10 03:52:53 -0500


Use shell module with double quotes,

This example works fine,

# ansible -m shell -a ". ~/ ; cinder list" testserver
testserver | success | rc=0 >>
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |

You can also use with a task file with something like this:

- name: Create cinder volume
  shell: . ~/ ; cinder create --display-name test1 1


edit flag offensive delete link more


I tried similar things as well see below

test@master:/etc/ansible$ ansible -m shell -a "source ~/ ; cinder list" devstack devstack | FAILED | rc=1 >> /bin/sh: 1: source: not found ERROR: You must provide a user name through --os-username or env[OS_USERNAME].

See my adminrc file : test

Maestropandy gravatar imageMaestropandy ( 2016-06-10 02:06:55 -0500 )edit

It works, that is the output from my command using ansible 1.9.4 from Ubuntu to a RedHat server. My rc file is called, check if yours is with all the necessary parameters and file name. Maybe at Devstack the file is different, i don't use devstack. Regards

Eduardo Gonzalez gravatar imageEduardo Gonzalez ( 2016-06-10 03:49:01 -0500 )edit

I remember that in the past, devstack adminrc needed to receive the user and password as parameter. You can also pass -e "OS_USERNAME=testuser" as environment parameter with ansible. Regards

Eduardo Gonzalez gravatar imageEduardo Gonzalez ( 2016-06-10 03:50:13 -0500 )edit

I realized, that adminrc at devstack is not a tipical rc file, is a script which not need to be sourced, it needs to be executed with the dot. I'll edit the answer.

Eduardo Gonzalez gravatar imageEduardo Gonzalez ( 2016-06-10 03:51:33 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2016-06-09 07:05:56 -0500

Seen: 836 times

Last updated: Jun 10 '16