Iterate over list of items from stdout

Hi

I would like to get list of items from stdout. Here is what I do:

tasks:

  • name: Get DB list
    shell: /usr/bin/get_db_list.sh
    register: dblist
  • name: dump dbs
    mysql_db: |
    login_user=root
    login_password=xxxxxx
    name={{ item }}
    state=dump
    target=/backup/backup-{{ item }}.sql
    with_items: dblist.stdout

The problem is that shell module returns list as one string, like: “stdout”: “Dev\nProd” and obviously mysql_db module takes it as one string (“Dev\nProd”) rather than two. So how can I tell module to iterate over dblist.stdout?

Thanks
Edgars

Change that to “dblist.stdout_lines” and you’ll be good to go!

Thanks a lot!

Now I have other problem, mysql_db module’s state=dump does not work:

ansible localhost -c local -u root -m mysql_db -a “login_password=xxxx login_user=root name=prod state=dump target=/backup/backup-prod.sql” -vvv

<17.0.0.1> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-1380549742.98-31810291682605 && echo $HOME/.ansible/tmp/ansible-1380549742.98-31810291682605’]
<17.0.0.1> REMOTE_MODULE mysql_db login_password=xxxxx login_user=root name=prod state=dump target=/backup/backup-prod.sql
<17.0.0.1> PUT /tmp/tmpdG_TMr TO /root/.ansible/tmp/ansible-1380549742.98-31810291682605/mysql_db
<17.0.0.1> EXEC [‘/bin/sh’, ‘-c’, ‘/usr/bin/python /root/.ansible/tmp/ansible-1380549742.98-31810291682605/mysql_db; rm -rf /root/.ansible/tmp/ansible-1380549742.98-31810291682605/ >/dev/null 2>&1’]
localhost | FAILED >> {
“failed”: true,
“msg”: “dump failed!”
}

I am pretty sure that MySQL service is running and user root can connect to it. Any ideas how can I find out why is it failing?

Edgars

pirmdiena, 2013. gada 30. septembris 15:43:33 UTC+2, Edgars rakstīja:

I agree that’s a pretty terrible error message and we should at least include stdout in this case.

Is this something you can file a github bug ticket on please?

Thanks for your help. Filed ticket 4301

Edgars

pirmdiena, 2013. gada 30. septembris 15:43:33 UTC+2, Edgars rakstīja: