---
- name: Generate a SECRET_KEY for NetBox if unspecified
  shell: "{{ netbox_current_path }}/netbox/generate_secret_key.py > {{ netbox_shared_path }}/generated_secret_key"
  args:
    creates: "{{ netbox_shared_path }}/generated_secret_key"

- name: Load saved SECRET_KEY
  slurp:
    src: "{{ netbox_shared_path }}/generated_secret_key"
  register: __netbox_secret_key_file

- name: Set netbox_secret_key to generated SECRET_KEY
  set_fact:
    netbox_secret_key: "{{ __netbox_secret_key_file['content'] | b64decode }}"

---
- name: Generate a SECRET_KEY for NetBox if unspecified
  shell: "{{ netbox_current_path }}/netbox/generate_secret_key.py | tr -d $'\n' > {{ netbox_shared_path }}/generated_secret_key"
  args:
    creates: "{{ netbox_shared_path }}/generated_secret_key"

- name: Load saved SECRET_KEY
  slurp:
    src: "{{ netbox_shared_path }}/generated_secret_key"
  register: __netbox_secret_key_file

- name: Set netbox_secret_key to generated SECRET_KEY
  set_fact:
    netbox_secret_key: "{{ __netbox_secret_key_file['content'] | b64decode }}"

Remove newline when generating SECRET_KEY
Remove newline when generating SECRET_KEY
