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

Keep failing Jenkins Master config at the [beaker-client : copy CA cert if necessary] task #257

Open
Dannyb48 opened this issue Sep 4, 2020 · 3 comments

Comments

@Dannyb48
Copy link
Contributor

Dannyb48 commented Sep 4, 2020

Trying to deploy a jenkins master in a a RHEL 7 VM with the following version of ansible and python

ansible 2.9.13
  config file = /home/dbaez/projects/jenks_cinch/jenkins_cinch_scenario/ansible.cfg
  configured module search path = ['/home/dbaez/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/dbaez/.virtualenvs/jenks_cinch/lib/python3.6/site-packages/ansible
  executable location = /home/dbaez/.virtualenvs/jenks_cinch/bin/ansible
  python version = 3.6.8 (default, Mar 21 2019, 10:08:12) [GCC 8.3.1 20190223 (Red Hat 8.3.1-2)]

The original error

"TASK [beaker-client : copy CA cert if necessary] *******************************",
2020-09-04 01:24:14,906 INFO [carbon.ansible_helpers.exec_local_cmd_pipe:558] "fatal: [10.0.101.40]: FAILED! => {\"msg\": \"No file was found when using first_found. Use errors='ignore' to allow this task to be skipped if no files are found\"}",

Closet thing I found was this ansible ticket ansible/ansible#58942

When I try the workaround mentioned in that ansible ticket, the error morphs to

TASK [beaker-client : copy CA cert if necessary] *******************************",
2020-09-04 14:33:09,838 INFO [carbon.ansible_helpers.exec_local_cmd_pipe:558] "fatal: [10.0.102.79]: FAILED! => {\"msg\": \"The task includes an option with an undefined variable. The error was: 'beaker_cacert_file' is undefined\\n\\nThe error appears to be in '/home/dbaez/projects/jenks_cinch/cinch/cinch/roles/beaker-client/tasks/main.yml': line 19, column 3, but may\\nbe elsewhere in the file depending on the exact syntax problem.\\n\\nThe offending line appears to be:\\n\\n\\n- name: copy CA cert if necessary\\n  ^ here\\n\"}",

Turns out that variable beaker_cacert_file is commented out in the beaker-client vars/defaults.yml. If I set to a blank value like this
beaker_cacert_file: ""

I still get problems but to be honest I don't have a need to use a custom cacert file because the certificate_authority role already sets some up by default for me.

Only way I could get passed this task to finalize the jenkins master config deployment successfully is with the following:

- name: copy CA cert if necessary
  become: true
  copy:
    src: "{{ lookup('first_found', bkrcert, errors='ignore') }}"
    dest: "{{ beaker_ca_cert_path }}"
    owner: root
    group: root
    mode: 0644
  vars:
    bkrcert:
      files:
        - "{{ beaker_cacert_file }}"
      skip: true
  when: beaker_cacert_file is defined
@Dannyb48 Dannyb48 changed the title Keep failing Jenkins Master config at the beaker-client : copy CA cert if necessary task Keep failing Jenkins Master config at the [beaker-client : copy CA cert if necessary] task Sep 4, 2020
Dannyb48 added a commit to Dannyb48/cinch that referenced this issue Sep 4, 2020
 * This should address issue RedHatQE#257 by declaring a when statement
   to check for that bkr variable for none custom ca cert use cases
   and changed up the first lookup logic per ansible ticket
   ansible/ansible#58942
@greg-hellings
Copy link
Contributor

That's a very convoluted construct. Can you try just setting when: beaker_cacert_file is file instead of all the obfuscation through vars and lookup and ignore errors?

@Dannyb48
Copy link
Contributor Author

Dannyb48 commented Sep 4, 2020

I agree. I'll give it a try and let you know.

@Dannyb48
Copy link
Contributor Author

so doing the following worked as well:

- name: copy CA cert if necessary
  become: true
  copy:
    src: "{{ beaker_cacert_file }}"
    dest: "{{ beaker_ca_cert_path }}"
    owner: root
    group: root
    mode: 0644
  when: beaker_cacert_file is defined and beaker_cacert_file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants