Skip to content

Commit

Permalink
fix: Use correct JWT location in FreeBSD
Browse files Browse the repository at this point in the history
* And add the option to specify the a destination location for the JWT file
  • Loading branch information
alessfg committed Nov 22, 2024
1 parent 24c87c3 commit 91aeac4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
6 changes: 5 additions & 1 deletion defaults/main/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ nginx_static_modules: [http_ssl_module]
# Default is mainline.
nginx_branch: mainline

# Location of your NGINX Plus license (certificate, key, and JWT) in your local machine. The license JWT is only required with NGINX Plus R33 and later.
# Location of your NGINX Plus license (certificate, key, and JWT) in your local machine. The license JWT is only required starting with NGINX Plus R33 and later.
# For the license JWT, you can optionally specify a custom destination path for the JWT by using the 'src' and 'dest' parameters.
# Default is the files folder within the NGINX Ansible role.
nginx_license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
jwt: license/license.jwt
# jwt:
# src: license/license.jwt
# dest: /etc/nginx/license.jwt

# Set up NGINX Plus license before installation.
# Default is true.
Expand Down
3 changes: 2 additions & 1 deletion molecule/uninstall-plus/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@
nginx_license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
jwt: license/license.jwt
jwt:
src: license/license.jwt
4 changes: 3 additions & 1 deletion molecule/upgrade-plus/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
nginx_license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
jwt: license/license.jwt
jwt:
src: license/license.jwt
dest: /etc/nginx/license.jwt
nginx_remove_license: false
nginx_setup: upgrade
10 changes: 5 additions & 5 deletions tasks/plus/setup-license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@

- name: Copy NGINX Plus JWT
ansible.builtin.copy:
src: "{{ nginx_license['jwt'] }}"
dest: /etc/nginx/license.jwt
src: "{{ nginx_license['jwt']['src'] | default(nginx_license['jwt']) }}"
dest: "{{ nginx_license['jwt']['dest'] | default((ansible_facts['os_family'] == 'FreeBSD') | ternary('/usr/local/etc/nginx/license.jwt', '/etc/nginx/license.jwt')) }}"
decrypt: true
mode: "0444"

- name: Verify NGINX Plus JWT claims
block:
- name: Read JWT file
ansible.builtin.slurp:
src: /etc/nginx/license.jwt
src: "{{ nginx_license['jwt']['dest'] | default((ansible_facts['os_family'] == 'FreeBSD') | ternary('/usr/local/etc/nginx/license.jwt', '/etc/nginx/license.jwt')) }}"
register: jwt_file

- name: Decode JWT payload using base64url
Expand All @@ -179,5 +179,5 @@
- jwt_payload['aud'] == 'urn:f5:teem'
- (ansible_facts['date_time']['epoch'] | int) >= jwt_payload['iat']
- (ansible_facts['date_time']['epoch'] | int) <= jwt_payload['f5_sat']
success_msg: 'JWT is valid'
fail_msg: 'JWT is invalid. Double check that the JWT data is correct.'
success_msg: Your NGINX Plus license JWT is valid!
fail_msg: Something went wrong! Make sure your NGINX Plus license JWT is valid!

0 comments on commit 91aeac4

Please sign in to comment.