|
17 | 17 | - "{{ nginx_license['certificate'] }}"
|
18 | 18 | - "{{ nginx_license['key'] }}"
|
19 | 19 |
|
| 20 | + - name: (Debian/Red Hat/SLES OSs) Install cryptography package |
| 21 | + ansible.builtin.package: |
| 22 | + name: "{{ (ansible_python['version']['major'] == 3) | ternary('python3-cryptography', 'python2-cryptography') }}" |
| 23 | + |
| 24 | + - name: (Debian/Red Hat/SLES OSs) Check that NGINX Plus certificate is valid |
| 25 | + community.crypto.x509_certificate_info: |
| 26 | + path: /etc/ssl/nginx/nginx-repo.crt |
| 27 | + register: cert |
| 28 | + |
| 29 | + - name: (Debian/Red Hat/SLES OSs) Check that NGINX Plus key is valid |
| 30 | + community.crypto.openssl_privatekey_info: |
| 31 | + path: /etc/ssl/nginx/nginx-repo.key |
| 32 | + register: key |
| 33 | + |
| 34 | + - name: (Debian/Red Hat/SLES OSs) Check that NGINX Plus license is valid |
| 35 | + ansible.builtin.assert: |
| 36 | + that: |
| 37 | + - cert.expired == false |
| 38 | + - cert.public_key == key.public_key |
| 39 | + success_msg: Your NGINX Plus license is valid! |
| 40 | + fail_msg: Something went wrong! Make sure your NGINX Plus license is valid! |
| 41 | + |
20 | 42 | - name: (SLES) Create NGINX Plus license bundle
|
21 | 43 | block:
|
22 | 44 | - name: (SLES) Check combined NGINX Plus license bundle exists
|
|
35 | 57 |
|
36 | 58 | - name: (Alpine Linux) Set up NGINX Plus license
|
37 | 59 | block:
|
| 60 | + - name: Install cryptography package |
| 61 | + ansible.builtin.package: |
| 62 | + name: py3-cryptography |
| 63 | + |
38 | 64 | - name: (Alpine Linux) Create APK directory
|
39 | 65 | ansible.builtin.file:
|
40 | 66 | path: /etc/apk
|
41 | 67 | state: directory
|
42 | 68 | mode: 0755
|
43 | 69 |
|
44 |
| - - name: (Alpine Linux) Copy NGINX Plus key |
| 70 | + - name: (Alpine Linux) Copy NGINX Plus certificate |
45 | 71 | ansible.builtin.copy:
|
46 |
| - src: "{{ nginx_license['key'] }}" |
47 |
| - dest: /etc/apk/cert.key |
| 72 | + src: "{{ nginx_license['certificate'] }}" |
| 73 | + dest: /etc/apk/cert.pem |
48 | 74 | decrypt: true
|
49 | 75 | mode: 0444
|
50 | 76 |
|
51 |
| - - name: (Alpine Linux) Copy NGINX Plus certificate |
| 77 | + - name: (Alpine Linux) Copy NGINX Plus key |
52 | 78 | ansible.builtin.copy:
|
53 |
| - src: "{{ nginx_license['certificate'] }}" |
54 |
| - dest: /etc/apk/cert.pem |
| 79 | + src: "{{ nginx_license['key'] }}" |
| 80 | + dest: /etc/apk/cert.key |
55 | 81 | decrypt: true
|
56 | 82 | mode: 0444
|
| 83 | + |
| 84 | + - name: (Alpine Linux) Check that NGINX Plus certificate is valid |
| 85 | + community.crypto.x509_certificate_info: |
| 86 | + path: /etc/apk/cert.pem |
| 87 | + register: cert |
| 88 | + |
| 89 | + - name: (Alpine Linux) Check that NGINX Plus key is valid |
| 90 | + community.crypto.openssl_privatekey_info: |
| 91 | + path: /etc/apk/cert.key |
| 92 | + register: key |
| 93 | + |
| 94 | + - name: (Alpine Linux) Check that NGINX Plus license is valid |
| 95 | + ansible.builtin.assert: |
| 96 | + that: |
| 97 | + - cert.expired == false |
| 98 | + - cert.public_key == key.public_key |
| 99 | + success_msg: Your NGINX Plus license is valid! |
| 100 | + fail_msg: Something went wrong! Make sure your NGINX Plus license is valid! |
57 | 101 | when: ansible_facts['os_family'] == "Alpine"
|
0 commit comments