From 543576c4dfd8d2c93ebd5a9904b97d2049933048 Mon Sep 17 00:00:00 2001 From: John Wong Date: Tue, 14 Mar 2023 05:15:13 +0000 Subject: [PATCH 1/6] Install 'cryptography' using 'pip' --- tasks/plus/install-pip2.yml | 17 +++++++++++++++++ tasks/plus/install-pip3.yml | 7 +++++++ tasks/plus/setup-license.yml | 7 +++++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tasks/plus/install-pip2.yml create mode 100644 tasks/plus/install-pip3.yml diff --git a/tasks/plus/install-pip2.yml b/tasks/plus/install-pip2.yml new file mode 100644 index 000000000..5433437fa --- /dev/null +++ b/tasks/plus/install-pip2.yml @@ -0,0 +1,17 @@ + - name: (Python 2) Get version 2.7 'pip' script + ansible.builtin.get_url: + url: "https://bootstrap.pypa.io/pip/2.7/get-pip.py" + dest: "/tmp/get-pip.py" + mode: "0755" + + - name: (Python 2) Check if 'pip' binary exists + ansible.builtin.stat: + path: /usr/bin/pip + ignore_errors: true + register: pip + + - name: (Python 2) Install 'pip' version 2.7 + ansible.builtin.command: "python get-pip.py" + args: + chdir: /tmp/ + when: not pip.stat.exists diff --git a/tasks/plus/install-pip3.yml b/tasks/plus/install-pip3.yml new file mode 100644 index 000000000..2f520467a --- /dev/null +++ b/tasks/plus/install-pip3.yml @@ -0,0 +1,7 @@ +- name: (Python 3) Install 'pip' package + ansible.builtin.package: + name: python3-pip + + - name: (Python 3) Ensure 'pip' is updated + ansible.builtin.pip: + name: pip>=21.2.4 diff --git a/tasks/plus/setup-license.yml b/tasks/plus/setup-license.yml index 7c7e212f1..2a8794ef5 100644 --- a/tasks/plus/setup-license.yml +++ b/tasks/plus/setup-license.yml @@ -47,6 +47,9 @@ - name: (Debian/Red Hat/SLES OSs) Set up NGINX Plus license when: ansible_facts['os_family'] != 'Alpine' block: + - name: (RedHat) Install pip + ansible.builtin.include_tasks: "{{ role_path }}/tasks/plus/install-pip{{ ansible_python['version']['major'] }}.yml" + - name: (Debian/Red Hat/SLES OSs) Create SSL directory ansible.builtin.file: path: /etc/ssl/nginx @@ -64,8 +67,8 @@ - "{{ nginx_license['key'] }}" - name: (Debian/Red Hat/SLES OSs) Install cryptography package - ansible.builtin.package: - name: "{{ (ansible_python['version']['major'] == 3) | ternary('python3-cryptography', 'python2-cryptography') }}" + ansible.builtin.pip: + name: cryptography - name: (Debian/Red Hat/SLES OSs) Check that NGINX Plus certificate is valid community.crypto.x509_certificate_info: From e0bb9589edefd3d8a37929a9629eb5979bf58bad Mon Sep 17 00:00:00 2001 From: John Wong Date: Wed, 15 Mar 2023 04:31:50 +0000 Subject: [PATCH 2/6] Fixing YAML error --- tasks/plus/install-pip2.yml | 30 +++++++++++++++--------------- tasks/plus/install-pip3.yml | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tasks/plus/install-pip2.yml b/tasks/plus/install-pip2.yml index 5433437fa..f83061b6a 100644 --- a/tasks/plus/install-pip2.yml +++ b/tasks/plus/install-pip2.yml @@ -1,17 +1,17 @@ - - name: (Python 2) Get version 2.7 'pip' script - ansible.builtin.get_url: - url: "https://bootstrap.pypa.io/pip/2.7/get-pip.py" - dest: "/tmp/get-pip.py" - mode: "0755" +- name: (Python 2) Get version 2.7 'pip' script + ansible.builtin.get_url: + url: "https://bootstrap.pypa.io/pip/2.7/get-pip.py" + dest: "/tmp/get-pip.py" + mode: "0755" - - name: (Python 2) Check if 'pip' binary exists - ansible.builtin.stat: - path: /usr/bin/pip - ignore_errors: true - register: pip +- name: (Python 2) Check if 'pip' binary exists + ansible.builtin.stat: + path: /usr/bin/pip + ignore_errors: true + register: pip - - name: (Python 2) Install 'pip' version 2.7 - ansible.builtin.command: "python get-pip.py" - args: - chdir: /tmp/ - when: not pip.stat.exists +- name: (Python 2) Install 'pip' version 2.7 + ansible.builtin.command: "python get-pip.py" + args: + chdir: /tmp/ + when: not pip.stat.exists diff --git a/tasks/plus/install-pip3.yml b/tasks/plus/install-pip3.yml index 2f520467a..0fa2ac1b7 100644 --- a/tasks/plus/install-pip3.yml +++ b/tasks/plus/install-pip3.yml @@ -2,6 +2,6 @@ ansible.builtin.package: name: python3-pip - - name: (Python 3) Ensure 'pip' is updated - ansible.builtin.pip: - name: pip>=21.2.4 +- name: (Python 3) Ensure 'pip' is updated + ansible.builtin.pip: + name: pip>=21.2.4 From c652bceb38e893fc402fd318ccdf629f6e5ddd89 Mon Sep 17 00:00:00 2001 From: John Wong Date: Wed, 15 Mar 2023 04:39:56 +0000 Subject: [PATCH 3/6] Fixing YAML error --- tasks/plus/install-pip3.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/plus/install-pip3.yml b/tasks/plus/install-pip3.yml index 0fa2ac1b7..dc325aeca 100644 --- a/tasks/plus/install-pip3.yml +++ b/tasks/plus/install-pip3.yml @@ -1,6 +1,6 @@ - name: (Python 3) Install 'pip' package - ansible.builtin.package: - name: python3-pip + ansible.builtin.package: + name: python3-pip - name: (Python 3) Ensure 'pip' is updated ansible.builtin.pip: From 12766b619d71489404544893ddf586e0d9021971 Mon Sep 17 00:00:00 2001 From: John Wong Date: Wed, 15 Mar 2023 04:51:11 +0000 Subject: [PATCH 4/6] Resovle lint error --- tasks/plus/install-pip2.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/plus/install-pip2.yml b/tasks/plus/install-pip2.yml index f83061b6a..3a67bd372 100644 --- a/tasks/plus/install-pip2.yml +++ b/tasks/plus/install-pip2.yml @@ -15,3 +15,5 @@ args: chdir: /tmp/ when: not pip.stat.exists + register: pip_install + changed_when: pip_install.changed From b00f3628e3513cefad13523a14f5dfbad9cdfd17 Mon Sep 17 00:00:00 2001 From: John Wong Date: Wed, 15 Mar 2023 04:52:28 +0000 Subject: [PATCH 5/6] Resolving linting error --- tasks/plus/setup-license.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/plus/setup-license.yml b/tasks/plus/setup-license.yml index 2a8794ef5..e81b14f77 100644 --- a/tasks/plus/setup-license.yml +++ b/tasks/plus/setup-license.yml @@ -68,7 +68,7 @@ - name: (Debian/Red Hat/SLES OSs) Install cryptography package ansible.builtin.pip: - name: cryptography + name: cryptography - name: (Debian/Red Hat/SLES OSs) Check that NGINX Plus certificate is valid community.crypto.x509_certificate_info: From d543117097d50438d8ffe305c7c70a652ae9b9ef Mon Sep 17 00:00:00 2001 From: John Wong Date: Tue, 28 Mar 2023 22:52:06 +0000 Subject: [PATCH 6/6] Fixing 'default' test since new nginx version released. --- molecule/default/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 74a71df7b..3a17dfeeb 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -30,4 +30,4 @@ chdir: "{{ ((ansible_facts['system'] | lower is not search('bsd')) | ternary('/etc/nginx', '/usr/local/sbin')) }}" changed_when: false register: version - failed_when: version is not search('1.23.3') + failed_when: version is not search('1.23.4')