ansible/ansible-modules-core

'dict object' has no attribute 'stdout'

prasanjit- opened this issue · 1 comments

Below is the snippet:

  - name: Get master log file from master host one
    shell: mysql -u root -e "show master status;" | grep -v 'File' | awk '{print $1}'
    when: inventory_hostname == 'master_one'
    register: mysql_log_one

  - name: Write to file
    shell:  echo "{{ master_two }} {{ slave_user }} {{ mysql_log_one.stdout }} {{ mysql_logpos_one.stdout }}"  > /tmp/test
    when: inventory_hostname == 'master_one'

Here, echoing to /tmp/test work fine. No errors are thrown by ansible about 'dict object' for {{ mysql_log_one.stdout }} .

But,
- name: Configure master one
shell: >
mysql -u root -NBe
'slave stop;CHANGE MASTER TO MASTER_HOST="{{ master_two }}", MASTER_USER="{{ slave_user }}", MASTER_PASSWORD="{{
your_pass }}", MASTER_LOG_FILE="{{ item }}";slave start;'
with_items: "{{ mysql_log_two.stdout }}"
when: inventory_hostname == 'master_one'
ignore_errors: True

does not work. mysql_log_two is another variable whose value is present!

Error msg:
TASK [Configure master one] ***************************************************
skipping: [master_two] => (item=mysql-bin.000066)
fatal: [master_one]: FAILED! => {"failed": true, "msg": "'dict object' has no attribute 'stdout'"}
...ignoring

You can see (item=mysql-bin.000066) i.e. item is getting the value from mysql_log_two.stdout

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide.