1

I'm using Ansible to do the automation of my systems.

I have an Ansible playbook that depends on two roles. The first role creates a user ("specific_user") on a remote server. The second role uses this user to do a bunch of stuff.

My first solution was the following (my playbook) :

---
- hosts: all

roles:
  - { role: ansible-role1, remote_user: root }
  - { role: ansible-role2, remote_user: specific_user }
...

However, I'm getting the following warning from Ansible when running it:

Using 'remote_user' as a role param has been deprecated.
In the future, these values should be entered in the `vars:` section for
roles, but for now we'll store it as both a param and an attribute..

What is the alternative ?

techraf
  • 64,883
  • 27
  • 193
  • 198
MMacphail
  • 541
  • 3
  • 19

1 Answers1

4

Currently this is only a warning message (until version 2.7 of Ansible).

As the message suggests, you need to change syntax to (using YAML in the example below, because it's more readable):

roles:
  - role: ansible-role1
    vars:
      remote_user: root
  - role: ansible-role2
    vars:
      remote_user: specific_user

...

techraf
  • 64,883
  • 27
  • 193
  • 198
  • Thanks, I didn't understood the warning now it's clear – MMacphail May 29 '17 at 09:05
  • 2
    I'm getting the following warning now : `Found variable using reserved name remote_user` and have some followups questions : 1) is your suggested syntax equivalent to { remote_user: root } ? 2) can you override role vars using this syntax ? – MMacphail May 31 '17 at 20:55
  • This is clearly in transition phase in Ansible. What version do you use? Were you using a different version when you asked the question? – techraf May 31 '17 at 21:05
  • I'm still using the same version : 2.3.0, and for Python 2.7.5. I'm gonna try to update ansible. – MMacphail May 31 '17 at 23:34