Ansible vs. multiple Azure subscriptions

15 views
Skip to first unread message

Wawrzek Niewodniczanski

unread,
Feb 19, 2019, 4:47:10 AM2/19/19
to ansible...@googlegroups.com
Hi,

I have Azure with multiple subscriptions and I wonder what's the best
way to switch between them. The main two methods described in docs
are:
- password, but I don't see a way to distinguish subscription
- service principal, I still trying to figure out if I can use the
same SP in many subscriptions.

How do you deal with this?

Wawrzek

Link to docs:
https://docs.ansible.com/ansible/latest/scenario_guides/guide_azure.html#providing-credentials-to-azure-modules

--
Dr Wawrzyniec Niewodniczański or Wawrzek for short
PhD in Quantum Chemistry & MSc in Molecular Engineering
WWW: http://wawrzek.name E-MAIL: jo...@wawrzek.name
Linux User #177124

ameya agashe

unread,
Feb 19, 2019, 6:08:29 AM2/19/19
to ansible...@googlegroups.com
Not sure how you deal but for me Azure CLI az login works best, login and just choose current subscription which you want to work on. Just change the current default subscription. Did you try with this approach? I liked this one. From memory, I don't think I created Service Principal for Ansible but yes for Terraform.

Ameya

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAC7-vpCXuF2BfM71md9yP2ukg8GAnBnbpd6zPXgvSHvYM%2BfWwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Jean-Yves LENHOF

unread,
Feb 19, 2019, 6:12:59 AM2/19/19
to ansible...@googlegroups.com, Wawrzek Niewodniczanski
Le 2019-02-19 10:46, Wawrzek Niewodniczanski a écrit :
> Hi,
>
> I have Azure with multiple subscriptions and I wonder what's the best
> way to switch between them. The main two methods described in docs
> are:
> - password, but I don't see a way to distinguish subscription
> - service principal, I still trying to figure out if I can use the
> same SP in many subscriptions.
>
> How do you deal with this?
>
> Wawrzek
>


Hi,

Perhaps, you can use environment to pass the good variables to the
relevant parts of your playbooks :
https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html

Regards,

JYL

Wawrzek Niewodniczanski

unread,
Feb 19, 2019, 7:20:18 AM2/19/19
to ansible...@googlegroups.com
On Tue, 19 Feb 2019 at 11:08, ameya agashe <ameya...@gmail.com> wrote:
> On Tue, Feb 19, 2019 at 8:47 PM Wawrzek Niewodniczanski <ma...@wawrzek.name> wrote:
[...]
>> I have Azure with multiple subscriptions and I wonder what's the best
>> way to switch between them.
[...]
>> How do you deal with this?

> Not sure how you deal but for me Azure CLI az login works best, login and just choose current subscription which you want to work on. Just change the current default subscription. Did you try with this approach? I liked this one. From memory, I don't think I created Service Principal for Ansible but yes for Terraform.

Thanks for suggestions. For now, I added my SP to another
subscription. Now can switch between them using `AZURE_PROFILE`
environment variable. A powerful (and scary) thing is that I can have
two different subscriptions in two different shells.

Thanks,
Wawrzek

Steve Townsend

unread,
Aug 9, 2019, 9:56:29 AM8/9/19
to Ansible Project
I'd love to hear more about this. Are you saying that you're able to authenticate and run playbooks to Azure just by using your az login session? No Service principle at all?


On Tuesday, 19 February 2019 11:08:29 UTC, ameya agashe wrote:
Not sure how you deal but for me Azure CLI az login works best, login and just choose current subscription which you want to work on. Just change the current default subscription. Did you try with this approach? I liked this one. From memory, I don't think I created Service Principal for Ansible but yes for Terraform.

Ameya

On Tue, Feb 19, 2019 at 8:47 PM Wawrzek Niewodniczanski <ma...@wawrzek.name> wrote:
Hi,

I have Azure with multiple subscriptions and I wonder what's the best
way to switch between them. The main two methods described in docs
are:
- password, but I don't see a way to distinguish subscription
- service principal, I still trying to figure out if I can use the
same SP in many subscriptions.

How do you deal with this?

Wawrzek

Link to docs:
https://docs.ansible.com/ansible/latest/scenario_guides/guide_azure.html#providing-credentials-to-azure-modules

--
Dr  Wawrzyniec Niewodniczański    or Wawrzek for short
  PhD in Quantum Chemistry  & MSc in Molecular Engineering
   WWW: http://wawrzek.name E-MAIL: jo...@wawrzek.name
      Linux User #177124

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages