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

duplicated role dependencies don't get executed #12108

Closed
thegiantbeast opened this issue Aug 26, 2015 · 8 comments
Closed

duplicated role dependencies don't get executed #12108

thegiantbeast opened this issue Aug 26, 2015 · 8 comments
Labels
bug This issue/PR relates to a bug. needs_info This issue requires further information. Please answer any outstanding questions.

Comments

@thegiantbeast
Copy link

Hi,

I've made a very basic gist to demonstrate the current issue that I'm having.

https://gist.github.com/thegiantbeast/90efb8cb1a08cdef8c0b

The problem is that { role: installVersion, pkgVersion: "{{ currentVersion }}" } is only executed once, although the currentVersion keeps changing between executions (check output).
I believe this is related with what I've seen people mention as 'signature', because the task content/variables never change between them, only the actual variables content.

I even tried with allow_duplicates: true before dependencies: but it didn't work either.
This might be related with #9578 and #11707 as well, but I can't confirm if that's the case.

The current workaround that I've found for this is to add an "extra" (read: never used) variable that changes between the execution "blocks". Example:

dependencies:
 - { role: checkVersion, version: "stable" }
 - { role: installVersion, pkgVersion: "{{ currentVersion }}", forceExec: "stable" }

 - { role: checkVersion, version: "beta" }
 - { role: installVersion, pkgVersion: "{{ currentVersion }}", forceExec: "beta" }

 - { role: checkVersion, version: "alpha" }
 - { role: installVersion, pkgVersion: "{{ currentVersion }}", forceExec: "alpha" }

But this is not scalable if you have a "block" with 10 or more roles.

Has anyone ever saw this issue?
Not 100% sure if this is a bug or an expected behaviour, and if it's an expected behaviour, what's the best way to do implement (other than adding an extra variable)?

@jimi-c
Copy link
Member

jimi-c commented Aug 27, 2015

Hi @thegiantbeast, what version of Ansible are you running? Most of these kinds of issues have been resolved in 2.0 (the current devel branch). If you're running 1.9.x or earlier, you may want to test this against the devel branch to see if it's still a problem.

@jimi-c jimi-c added bug_report needs_info This issue requires further information. Please answer any outstanding questions. labels Aug 27, 2015
@thegiantbeast
Copy link
Author

Hi @jimi-c, I've just used the latest version (HEAD) and it still happens.

Also I've also found (on 2.0) that in the inventories I can't define the host like:

[my.host]
myUser@127.0.0.1:1234

I had to use:

[my.host]
127.0.0.1:1234 ansible_ssh_user=myUser

Is this a "new" behaviour? Meaning, it's not possible to define the user like the first example?

@jimi-c
Copy link
Member

jimi-c commented Aug 31, 2015

@thegiantbeast that's odd, the inventory parsing code has hardly been touched in 2.0, unless that parsing was happening somewhere else.

In regards to your other problem, I believe the issue is you're putting the allow_dependencies in the wrong role - it needs to be in the one you actually want to run more than once (which in your example is both checkcersion and installversion).

@amenonsen
Copy link
Contributor

That's strange. myUser@127.0.0.1:1234 works for me right now in devel, but I'd say it's really only by accident (and if it was ever documented, I certainly don't know about it). The port specification is correctly interpreted and removed, and the rest is handed as-is to ssh(1), so it "works".

@jimi-c is that a form we really want to support? (Note that ansible in this case will have no idea that ansible_ssh_user has been overriden for that host, so if there's a conflicting group var, say, it'll add -o User=thatuser to the ssh command line).

I don't understand why it works for me and not @thegiantbeast though.

@thegiantbeast
Copy link
Author

@jimi-c I've changed the allow_duplicates place to the modules that you mentioned and now it works correctly (I'll give a couple of more tries, but so far so good), thanks.
Is there an option to set all the dependencies as allow_duplicates by default?

@amegianeg I think I found why, but will give more detail tomorrow, but it seems the problem is not at the ssh connection.

@jimi-c
Copy link
Member

jimi-c commented Aug 31, 2015

@thegiantbeast no, not currently, the allow_duplicates setting is not inherited. Since this is resolved for you, I'll go ahead and close this now.

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!

@jimi-c jimi-c closed this as completed Aug 31, 2015
@jimi-c
Copy link
Member

jimi-c commented Aug 31, 2015

@thegiantbeast regarding the user@host, I'm not inclined to consider that a bug, as we've never really supported that and it's only working by accident in older versions. As we typically include the -U option in the ssh command args, it's apt to break depending on usage so I would recommend correctly setting ansible_ssh_user as you found.

Thanks!

@thegiantbeast
Copy link
Author

@jimi-c yep, that's fine. I was just confirming if it was an expected behaviour or not, since I noticed the difference between the versions.

Thanks for all the help.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 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. needs_info This issue requires further information. Please answer any outstanding questions.
Projects
None yet
Development

No branches or pull requests

4 participants