From 6e81ce576cdd05c574f12b5f60139a7f71aa6055 Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Mar 28 2023 14:04:30 +0000 Subject: Add KRB5CCNAME envvar to fix kerberos issue --- diff --git a/Makefile b/Makefile index 2b2793a..97677e9 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # To re-generate a bundle for another specific version without changing the standard setup, you can: # - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2) # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) -VERSION ?= 0.0.27 +VERSION ?= 0.0.33 # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") @@ -29,8 +29,10 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) # # For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both # fas2discourse.apps.fedoraproject.org/fas2discourse-bundle:$VERSION and fas2discourse.apps.fedoraproject.org/fas2discourse-catalog:$VERSION. +#IMAGE_TAG_BASE ?= quay.io/fedora/fas2discourse-operator IMAGE_TAG_BASE ?= quay.io/fedora/fas2discourse-operator + # BUNDLE_IMG defines the image:tag used for the bundle. # You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=/:) BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index ed71794..7285fdf 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -13,4 +13,4 @@ kind: Kustomization images: - name: controller newName: quay.io/fedora/fas2discourse-operator - newTag: v0.0.27 + newTag: v0.0.33 diff --git a/config/samples/_v1alpha1_fas2discourseconfig.yaml b/config/samples/_v1alpha1_fas2discourseconfig.yaml index e03066e..c037f4c 100644 --- a/config/samples/_v1alpha1_fas2discourseconfig.yaml +++ b/config/samples/_v1alpha1_fas2discourseconfig.yaml @@ -2,5 +2,7 @@ apiVersion: fas2discourse.apps.fedoraproject.org/v1alpha1 kind: Fas2discourseConfig metadata: name: fas2discourseconfig-sample + annotations: + "ansible.sdk.operatorframework.io/verbosity": "5" spec: # TODO(user): Add fields here diff --git a/roles/fas2discourseconfig/library/fas2discourse_retrieve_fasjson_data.py b/roles/fas2discourseconfig/library/fas2discourse_retrieve_fasjson_data.py index 3cef472..45834d4 100644 --- a/roles/fas2discourseconfig/library/fas2discourse_retrieve_fasjson_data.py +++ b/roles/fas2discourseconfig/library/fas2discourse_retrieve_fasjson_data.py @@ -8,8 +8,10 @@ import json import requests from ansible.module_utils.basic import AnsibleModule +from ansible.utils.display import Display from requests_kerberos import HTTPKerberosAuth +display = Display(verbosity=5) __metaclass__ = type DOCUMENTATION = r""" @@ -103,7 +105,8 @@ def get_http_client(keytab_path, principal): # Helper function to retrieve fasjson groups def get_groups(http_client): - response = http_client.get("%sgroups/" % ("https://fasjson.fedoraproject.org/v1/")) + response = http_client.get("https://fasjson.fedoraproject.org/v1/groups/") + display.debug(f"Response from get_groups: {response}, {response.json()}, {response.status_code}") if response.ok: return response.json() @@ -148,9 +151,7 @@ def run_module(): # part where your module will do what it needs to do) keytab_path = module.params["keytab_path"] principal = module.params["principal"] -# discourse_groups = module.params["discourse_groups"] - # let's hardcode the discourse groups for the moment - discourse_groups = ["council", "moderators", "design", "magazine_editors", "community-blog", "pgm-team"] + discourse_groups = module.params["discourse_groups"] try: http_client = get_http_client(keytab_path, principal) diff --git a/roles/fas2discourseconfig/tasks/retrieve_discourse_groups.yml b/roles/fas2discourseconfig/tasks/retrieve_discourse_groups.yml index b66e97d..587ca7c 100644 --- a/roles/fas2discourseconfig/tasks/retrieve_discourse_groups.yml +++ b/roles/fas2discourseconfig/tasks/retrieve_discourse_groups.yml @@ -28,6 +28,8 @@ discourse_ignored_groups: "{{ discourse_ignored_groups }}" register: fas2discourse_retrieve_discourse_groups_response +- set_fact: + discourse_groups: "{{ fas2discourse_retrieve_discourse_groups_response['discourse_groups'] }}" - name: Prints the groups ansible.builtin.debug: diff --git a/roles/fas2discourseconfig/tasks/retrieve_ipa_groups.yml b/roles/fas2discourseconfig/tasks/retrieve_ipa_groups.yml index bac9b16..9844cc0 100644 --- a/roles/fas2discourseconfig/tasks/retrieve_ipa_groups.yml +++ b/roles/fas2discourseconfig/tasks/retrieve_ipa_groups.yml @@ -1,12 +1,14 @@ --- # tasks file for fas2discourse -- name: Retrieve fasjson group/user data based on pattern supplied +- name: Retrieve fasjson group/user data based on the discourse group fas2discourse_retrieve_fasjson_data: keytab_path: "{{ fas2discourse_keytab_path }}" principal: "{{ fas2discourse_principal }}" discourse_groups: "{{ discourse_groups }}" register: fasjson_response + environment: + KRB5CCNAME: /tmp/ticket - name: Set fact set_fact: @@ -16,6 +18,3 @@ ansible.builtin.debug: msg: - "Groups found: {{ fas2discourse_fasjson_response }}" - -- name: Write groups to json file - copy: content="{{ fas2discourse_fasjson_response }}" dest=/tmp/fasjson_groups.json