Abhijeet, I need one more help, from the above playbook I am trying to check if the job exists on 2 jenkins urls. Now, I am trying to configure job if the doesn't exist on any of the jenkins, for this I have to look for job if exists. I am little confused how to check the condition.
On Friday, June 30, 2023 at 4:42:27 PM UTC-7 Abhijeet Kasurde wrote: > Hi Narmada, > > I just showed you an example. You can directly use `jekins_job_info` in a > similar way. > > On Fri, Jun 30, 2023 at 4:09 PM Narmada Karthika <[email protected]> > wrote: > >> >> any suggestions how I can use the password from this debug as variable in >> next play >> - debug: >> msg: "{{ (lookup('file', url_item.password_file >> )|from_yaml).password }}" >> On Friday, June 30, 2023 at 12:48:32 PM UTC-7 Narmada Karthika wrote: >> >>> Also I would I use that password item in the below play >>> >>> On Fri, Jun 30, 2023 at 12:16 PM Abhijeet Kasurde <[email protected]> >>> wrote: >>> >>>> Hi Narmada, >>>> >>>> I would suggest you to remove include_vars if you want to read the >>>> variables from files. Instead of that you can simplify the task like - >>>> >>>> ``` >>>> vars: >>>> urls: >>>> - url: url1 >>>> username: username1 >>>> password_file: group_vars/password1.yml >>>> - url: url2 >>>> username: username2 >>>> password_file: group_vars/password2.yml >>>> tasks: >>>> - debug: >>>> msg: "{{ (lookup('file', url_item.password_file >>>> )|from_yaml).password }}" >>>> loop: "{{ urls }}" >>>> loop_control: >>>> loop_var: url_item >>>> ``` >>>> >>>> I am assuming your password*.yml file looks like this = >>>> ``` >>>> # cat group_vars/password1.yml >>>> --- >>>> password: sample1 >>>> ``` >>>> >>>> >>>> On Fri, Jun 30, 2023 at 11:09 AM Narmada Karthika <[email protected]> >>>> wrote: >>>> >>>>> thankyou, I have some typos, fixed that issue. BUt in the same >>>>> playbook I trying to use loops and access both the urls with respective >>>>> user and password and print the job info, but only one url response is >>>>> working. other one is failing with error. if I remove the working url and >>>>> try with accessing the failed user details, it works. I believe some >>>>> thing >>>>> I might have missed in the loop. >>>>> >>>>> --- >>>>> - name: Access URLs with Different User-Password Combinations >>>>> hosts: localhost >>>>> gather_facts: false >>>>> >>>>> vars: >>>>> urls: >>>>> - url: <url1> >>>>> username: <username1> >>>>> password_file: group_vars/password1.yml >>>>> - url: <url1> >>>>> username: <username2> >>>>> password_file: group_vars/password2.yml >>>>> >>>>> tasks: >>>>> - name: Include Password Variables >>>>> include_vars: >>>>> file: "{{ url_item.password_file }}" >>>>> loop: "{{ urls }}" >>>>> loop_control: >>>>> loop_var: url_item >>>>> >>>>> >>>>> - name: Access URLs >>>>> community.general.jenkins_job_info: >>>>> glob: "reponame.*" >>>>> url: "{{ url_item.url }}" >>>>> user: "{{ url_item.username }}" >>>>> token: "{{ password }}" >>>>> validate_certs: false >>>>> loop: "{{ urls }}" >>>>> loop_control: >>>>> loop_var: url_item >>>>> vars: >>>>> - password: "{{ url_item.password_file }}" >>>>> register: response >>>>> >>>>> - name: Print Response >>>>> debug: >>>>> var: response >>>>> >>>>> On Friday, June 30, 2023 at 4:28:42 AM UTC-7 Dick Visser wrote: >>>>> >>>>>> On Fri, 30 Jun 2023 at 09:22, Narmada Karthika <[email protected]> >>>>>> wrote: >>>>>> >>>>>> > msg": "Unable to connect to Jenkins server, Unable to authenticate >>>>>> with any scheme:\nauth(kerberos) HTTPSConnectionPool(host='< >>>>>> jenkins.com>.*', port=443): Max retries exceeded with url: /api/json >>>>>> (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection >>>>>> object >>>>>> at 0x7f4fcb26bd30>: Failed to establish a new connection: [Errno -2] >>>>>> Name >>>>>> or service not known',))\nauth(basic) HTTPSConnectionPool(host=' < >>>>>> jenkins.com>.* ', port=443): Max retries exceeded with url: >>>>>> /api/json (Caused by >>>>>> NewConnectionError('<urllib3.connection.HTTPSConnection object at >>>>>> 0x7f4fcb26b9e8>: Failed to establish a new connection: [Errno -2] Name >>>>>> or >>>>>> service not known',))", >>>>>> >>>>>> This indicates some DNS resolution issue on the system where this >>>>>> task executes. >>>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Ansible Project" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/ansible-project/e5d45eb6-54e7-49e4-a261-92657c03ef10n%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/ansible-project/e5d45eb6-54e7-49e4-a261-92657c03ef10n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> >>>> >>>> -- >>>> Thanks, >>>> Abhijeet Kasurde >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ansible Project" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> >>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/ansible-project/CAFwWkHoFo9c1Rk8LB4UziikzezGYpAFQaOPLC5LjyryUzbP%2BvA%40mail.gmail.com >>>> >>>> <https://groups.google.com/d/msgid/ansible-project/CAFwWkHoFo9c1Rk8LB4UziikzezGYpAFQaOPLC5LjyryUzbP%2BvA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >>> Thanks, >>> Narmada Karthika Chitturi >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/44453cbc-87d8-4abb-ac06-3f7cde48bfe9n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/44453cbc-87d8-4abb-ac06-3f7cde48bfe9n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Thanks, > Abhijeet Kasurde > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/46b88b96-00a1-40c4-adc6-d8877741f8fcn%40googlegroups.com.
