Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdout can not be retried for ansible v2.0 #13591

Closed
huikang opened this issue Dec 17, 2015 · 6 comments
Closed

stdout can not be retried for ansible v2.0 #13591

huikang opened this issue Dec 17, 2015 · 6 comments
Labels
bug This issue/PR relates to a bug.
Milestone

Comments

@huikang
Copy link

huikang commented Dec 17, 2015

I have the following code working for ansible 1.9.4.

register: haproxy_user
  changed_when: "{{ results.stdout.find('localhost | SUCCESS => ') != -1 and (results.stdout.split('localhost | S\
UCCESS => ')[1]|from_json).changed }}"
  until: "{{ results.stdout.split()[2] == 'SUCCESS' }} "
  retries: 10
  delay: 5

However, after I upgrading to v2.0. It returns the error as

TASK [mariadb : Creating  mysql user] ***********************************
fatal: [10.0.0.1]: FAILED! => {"failed": true, "msg": "ERROR! 'ansible.parsing.yaml.objects.AnsibleUnicode object' has no attribute 'stdout'"}

Can anyone help? Thanks.

My system is
ansible 2.0.0
ubuntu 15.04

@abadger
Copy link
Contributor

abadger commented Dec 17, 2015

where is your playbook getting result from?

@huikang
Copy link
Author

huikang commented Dec 17, 2015

From ansible's mysql_user module. It creates a new user in the database. Thanks. -Hui

@abadger
Copy link
Contributor

abadger commented Dec 17, 2015

Could you give us more of your playbook? In what you pasted initially, I only see you registering haproxy_user, not results.

@huikang
Copy link
Author

huikang commented Dec 17, 2015

@abadger Sorry about the confusion. The code is

- name: Creating haproxy mysql user
  mysql_user:
      login_host: '10.0.0.1'
      login_port: '3066'
      login_user: 'root'
      login_password: 'passwor9'
      name: 'haproxy'
  register: haproxy_user
  changed_when: "{{ haproxy_user.stdout.find('localhost | SUCCESS => ') != -1 and (haproxy_user.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
  until: haproxy_user.stdout.split()[2] == 'SUCCESS'
  retries: 10
  delay: 5

The failure is caused by the above until statement.

The code runs without any problem for ansible 1.9.4. But it fails using ansible 2.0.

  • Hui

@huikang
Copy link
Author

huikang commented Dec 18, 2015

@abadger just to check if you have found out anything. Thanks.

@jimi-c jimi-c added this to the v2 milestone Dec 18, 2015
@jimi-c jimi-c closed this as completed in a3dcb91 Dec 18, 2015
jimi-c added a commit that referenced this issue Dec 18, 2015
* Saving of the registered variable was occuring after the tests for
  changed/failed_when.
* Each of the above fields and until were being post_validated too early,
  so variables which were not defined at that time were causing task
  failures.

Fixes #13591
@jimi-c
Copy link
Member

jimi-c commented Dec 18, 2015

Closing This Ticket

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants