Impossible to use "with_subelements"...

22 views
Skip to first unread message

Clément VALENTIN

unread,
Apr 20, 2016, 5:28:07 AM4/20/16
to Ansible Project
Hi,

I try to use function "with_subelements" with module mysql_user to create an user with multiple host with a dict.
But i can't do this :(

roles/vars/main.yml :

TEST:
  - name: TEST300
    app_MySQLHost:              "127.0.0.1"
    app_MySQLPort:              "3306"
    app_MySQLAuth:              "{{ mysql_auth_file }}"
    app_MySQLDatabase:          "TEST"
    app_MySQLUser:              "TEST"
    app_MySQLAuthorizeHostname:
      - '127.0.0.1'
      - '192.168.0.1'

roles/tasks/main.yml

- name: "[MySQL] Check user"
  mysql_user:
    name: "{{ item.0.app_MySQLUser }}"
    host: "{{ item.1 }}"
    login_host: "{{ item.0.app_MySQLHost }}"
    login_port: "{{ item.0.app_MySQLPort }}"
    config_file: "{{ item.0.app_MySQLAuth }}"
    password: "{{ lookup('password', 'roles/TEST/credentials/mysql.pass length=15 chars=ascii_letters,digits') }}"
    update_password: on_create
    priv: "{{ item.0.app_MySQLUser }}.*:ALL"
    state: present
  with_subelements:
    - "{{ project }}"
    - app_MySQLAuthorizeHostname

But ansible return :
[WARNING]: Failure when attempting to use callback plugin (<ansible.plugins.callback.default.CallbackModule object at 0x1a42350>): not all arguments converted during string formatting

Any idea ?

Thx
Message has been deleted

Clément VALENTIN

unread,
Apr 20, 2016, 5:30:17 AM4/20/16
to Ansible Project
My Ansible version => 2.1.0

Reply all
Reply to author
Forward
0 new messages