Code Monkey home page Code Monkey logo

ansible-role-nginx-management-suite's Introduction

Molecule CI/CD License

Ansible NGINX Management Suite Role

This role only installs NGINX Management Suite (NMS).

Note: This role is still in active development. There may be unidentified issues and the role variables may change as development continues.

Requirements

  1. NGINX Management Suite License Files
  2. NGINX Ansible Role (nginxinc.nginx)

NGINX Management Suite Certificate Files

Installing NMS requires the NMS certificate files to access the repository. Log in to MyF5 or follow the link in the trial activation email to download the NMS repo .crt and .key files:

  • nginx-mgmt-suite-trial.key
  • nginx-mgmt-suite-trial.crt

NOTE: Be sure to rename these files to nginx-repo.key and nginx-repo.crt, respectively.

NGINX Instance

NMS requires an NGINX instance, either NGINX OSS or NGINX Plus as a frontend only. This role handles this by defining a dependency to the NGINX Ansible Role, named nginxinc.nginx. Because of this dependance, you can set variables related to nginxinc.nginx when using this role. For example, nginx_type is an nginxinc.nginx variable that can be set like how you would any other Ansible variable. So if your playbook defines nginx_type: plus, this NMS role will call the nginxinc.nginx role which will install NGINX Plus. Refer to the Ansible Role NGINX for more details.

Main difference between using NGINX OSS or NGINX Plus depends on which Authentication Option you plan to use.

Ansible

  • This role is developed and tested with maintained versions of Ansible core (above 2.12).

  • This role was developed and tested using nginxinc.nginx version 0.24.0.

  • When using this role, you will also need to install the following collections below. Additional information installing these collections is below in the Installation section.

    • ansible.posix
    • community.general
    • community.crypto
    • community.docker (Only required if you plan to use Molecule)
  • You will need to run this role as a root user using Ansible's become parameter. Make sure you have set up the appropriate permissions on your target hosts.

  • Instructions on how to install Ansible can be found in the Ansible website.

Jinja2

  • This role uses Jinja2 templates. Ansible core installs Jinja2 by default, but depending on your install and/or upgrade path, you might be running an outdated version. The minimum version of Jinja2 required for the role to properly function is 3.1.
  • Instructions on how to install Jinja2 can be found in the Jinja2 website.

Molecule (Optional)

You will want to use this if you are making contributions to this ansible role.

  • Molecule is used to test the various functionalities of the role. The recommended version of Molecule to test this role is 4.0.1.

  • Instructions on how to install Molecule can be found in the Molecule website. You will also need to install the Molecule Docker driver.

  • To run the Molecule tests, you must copy your NMS license to the role's files/license folder.

    You can alternatively add your NGINX Management Suite repository certificate and key to the local environment. Run the following commands to export these files as base64-encoded variables and execute the Molecule tests:

    export NGINX_CRT=$( cat <path to your certificate file> | base64 )
    export NGINX_KEY=$( cat <path to your key file> | base64 )
    molecule test -s plus

Usage

Take these steps in order to install NGINX Management Suite (nms) using this ansible role.

Create Inventory File

You will want to create an inventory file, inventory, with the following contents.

[nms]
<hostname> ansible_user=<adminUserName>  ansible_become=yes

Install Required Roles and Collections

You will want to install the package requirements this role requires. Create a requirements.yml file with the below content

---
roles:
  - name: nginxinc.nginx_management_suite
    version: 0.3.0
collections:
  - name: ansible.posix
    version: 1.5.1
  - name: community.general
    version: 6.4.0
  - name: community.crypto
    version: 2.11.0
  - name: community.docker # Only required if you plan to use Molecule (see below)
    version: 3.4.2

Use the command to install the ansible role and collections.

ansible-galaxy install -r requirements.yml

If you already have these installed but need to update to newer versions, use the below command.

ansible-galaxy install -fr requirements.yml

Move NGINX Certificates to a Known Location

In this example here, we will move the NGINX certificates to the same directory where I will be creating the NMS install playbook file.

Create Playbook

Create a playbook file, nms-install.yml, using the following example. Here, we are installing NMS with NGINX Plus.

Be sure to specify the path where your NGINX certificates are located. In the example here, they are in the same path as this playbook.

- name: Install NGINX Management Suite
  hosts: nms

  tasks:
    - name: Install NMS
      ansible.builtin.include_role:
        name: nginxinc.nginx_management_suite
      vars:
        nms_setup: install
        nms_user_name: admin
        nms_user_passwd: default
        nginx_type: plus
        nginx_selinux: true
        nginx_selinux_enforcing: false
        nginx_license:
          certificate: nginx-repo.crt
          key: nginx-repo.key

Install NMS

Run the following command to run the playbook which will install NMS.

ansible-playbook -i inventory nms-adm-install.yml

Using Latest Edge of NMS Ansible Role, aka the main Branch

There is a couple methods if you want to use the latest edge from this role.

  1. Use the following snippet in your requirement.yml.

    roles:
      - src: https://github.com/nginxinc/ansible-role-nginx-management-suite.git
        version: main
  2. Use git clone https://github.com/nginxinc/ansible-role-nginx-management-suite.git to pull the latest edge commit (the main branch) of the role from GitHub.

Platforms

This Ansible role supports all platforms supported by NGINX Management Suite:

NGINX Management Suite

Amazon Linux 2:
  - any
CentOS:
  - 7.4+
Debian:
  - buster (10)
  - bullseye (11)
Oracle Linux:
  - 7.4+
  - 8
Red Hat:
  - 7.4+
  - 8
  - 9
Ubuntu:
  - bionic (18.04)
  - focal (20.04)
  - jammy (22.04)

Note: You can also use this role to install NGINX Management Suite on compatible yet unsupported platforms at your own risk.

Role Variables

This role has multiple variables. The descriptions and defaults for all these variables can be found in the defaults/main/ folder in the following file:

Name Description
main.yml NMS installation variables

Similarly, descriptions and defaults for preset variables can be found in the vars/ folder in the following file:

Name Description
main.yml List of supported NMS installation variables

Example Playbooks

Working functional playbook examples can be found in the molecule/ folder in the following files:

Name Description
default/converge.yml Install NGINX OSS and NMS
plus/converge.yml Install NGINX Plus and NMS
upgrade/converge.yml Upgrade NMS
modules/converge.yml Install NGINX OSS and NMS & the API Connectivity Manager module
service-stopped/converge.yml Install NGINX OSS and NMS, allow services to be in the chosen state

Do note that if you install this repository via Ansible Galaxy, you will have to replace the role variable in the sample playbooks from ansible-role-nginx-management-suite to nginxinc.nginx_management_suite.

Other NGINX Ansible Collections and Roles

You can find the Ansible NGINX Core collection of roles to install and configure NGINX Open Source, NGINX Plus, and NGINX App Protect here.

You can find the Ansible NGINX configuration role to configure NGINX here.

You can find the Ansible NGINX Unit role to install NGINX Unit here.

License

Apache License, Version 2.0

Author Information

John Wong

Alessandro Fael Garcia

© F5, Inc. 2023

ansible-role-nginx-management-suite's People

Contributors

alessfg avatar dependabot[bot] avatar jswongf5 avatar nginx-danieloc avatar pdabel avatar pdabelf5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-nginx-management-suite's Issues

nomenclature and naming conventions

I have recently discovered the term "controller" must only apply to the old version 3 controller, and not to the current version4 aka nms. there is still lingering use of the term "controller" all over the place, not just this repo, but I wanted to open this issue to see if we can replace in this repo, as much as possible, the term controller with the term nms. second piece of naming convention is "modules" so think about how we start using the term "modules" for things like adding in ACM and ADM because those are "modules"

Cleaning NGINX Management Suite repository after installation prevents nms-nap-compiler manual install

Describe the bug

After installing NGINX Management Suite on Debian/Ubuntu the file /etc/apt/sources.list.d/nms.list is removed through tasks/nms/remove-certs.yaml together with the NGINX license certificate and key. This makes it impossible to find & install nms-nap-compiler-*.

To reproduce

Steps to reproduce the behavior:

  1. Deploy the Ansible NGINX Management Suite role using playbook.yml
  2. Run apt-cache search nms-nap-compiler
  3. No packages are found

Expected behavior

After installing NGINX Management Suite using this role it should be possible to apt-get install the nms-nap-compiler module without having to recreate /etc/apt/sources.list.d/nms.list

Your environment

  • Ansible NGINX Management Suite role 0.3.0
  • Version of Ansible: ansible [core 2.12.10]
  • Target deployment platform: Ubuntu 20.04

Changing the nms_cred_path breaks NMS

Describe the bug

The nms_cred_path cannot be changed. If it is then NGINX in front of NMS cannot find the password file.

To reproduce

Steps to reproduce the behavior:

  1. Create a playbook like the following
- hosts: nms
  become: yes
  vars:
    nginx_license:
      certificate: ./nginx-repo.crt
      key: ./nginx-repo.key
    nms_setup: install
    nms_cred_path: /etc/.htpasswd
  collections:
    - nginxinc.nginx_core
  roles:
    - ansible-role-nginx-management-suite
  1. Deploy the Ansible NGINX Management Suite role using playbook.yml

Expected behavior

NMS works after setting variables

Your environment

  • Version of the Ansible NGINX Management Suite role or specific commit - 0.3.0
  • Version of Ansible - 2.12

Additional context

Add any other context about the problem here.

Enable upgrade testing for AL2

Describe the bug

Upgrade test is failing for Amazon Linux 2. Need to investigate.

Only snippets from output below.

molecule test  -s upgrade
. . .
INFO     Running upgrade > converge

PLAY [Converge] ****************************************************************
. . .
TASK [ansible-role-nginx-management-suite : (Amazon) Configure NGINX Management Suite Yum repository] ***
skipping: [centos-7]
skipping: [oraclelinux-7]
skipping: [oraclelinux-8]
skipping: [rhel-7]
skipping: [rhel-8]
changed: [amazonlinux-2]

TASK [ansible-role-nginx-management-suite : (Amazon Linux/CentOS/Oracle Linux/RHEL) Upgrade NGINX Instance Manager] ***
ok: [amazonlinux-2]  <=== This should have 'changed'!
changed: [rhel-7]
changed: [rhel-8]
changed: [oraclelinux-7]
changed: [centos-7]
changed: [oraclelinux-8]

. . .

INFO     Idempotence completed successfully.
INFO     Running upgrade > side_effect
WARNING  Skipping, side effect playbook not configured.
INFO     Running upgrade > verify
INFO     Running Ansible Verifier
. . .
TASK [(RedHat) Verify correct version of NGINX has been installed] *************
. . .
fatal: [amazonlinux-2]: FAILED! => {"changed": false, "cmd": ["rpm", "-qa", "nms-instance-manager"], "delta": "0:00:01.098058", "end": "2023-01-30 18:25:57.432090", "failed_when_result": true, "msg": "", "rc": 0, "start": "2023-01-30 18:25:56.334032", "stderr": "", "stderr_lines": [], "stdout": "nms-instance-manager-2.4.0-614112268~amzn2-1.x86_64", "stdout_lines": ["nms-instance-manager-2.4.0-614112268~amzn2-1.x86_64"]}
ok: [oraclelinux-7]
. . .

PLAY RECAP *********************************************************************
amazonlinux-2              : ok=6    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Clean install doesn't work on RH7

Describe the bug

When running the install on Red Hat 7 machine it fails on prerequisites/setup-certs.yml:17

To reproduce

Steps to reproduce the behavior:

  1. Deploy the Ansible NGINX Management Suite role using playbook.yml
    Used example playbook here https://github.com/nginxinc/ansible-role-nginx-management-suite/blob/main/molecule/default/converge.yml

  2. View ansible output

  3. See error

TASK [ansible-role-nginx-management-suite : (Debian/Red Hat) Install cryptography package] ***********************************************************************************************************************************
task path: /Users/ch.adams/git/github/ansible-inventory/roles/ansible-role-nginx-management-suite/tasks/prerequisites/setup-certs.yml:17
fatal: [x.x.x.x]: FAILED! => {"changed": false, "cmd": ["/usr/bin/python", "-m", "pip.__main__", "install", "cryptography"], "msg": "stdout: Collecting cryptography\n  Using cached https://files.pythonhosted.org/packages/19/8c/47f061de65d1571210dc46436c14a0a4c260fd0f3eaf61ce9b9d445ce12f/cryptography-41.0.1.tar.gz\n    Complete output from command python setup.py egg_info:\n    Traceback (most recent call last):\n      File \"<string>\", line 1, in <module>\n      File \"/tmp/pip-build-U4n8D6/cryptography/setup.py\", line 87\n        print(f\"    Python: {'.'.join(str(v) for v in sys.version_info[:3])}\")\n                                                                            ^\n    SyntaxError: invalid syntax\n    \n    ----------------------------------------\n\n:stderr: Command \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-build-U4n8D6/cryptography/\nYou are using pip version 8.1.2, however version 23.1.2 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n"}

Expected behavior

A clear and concise description of what you expected to happen.
NMS to install successfully

Your environment

  • Version of the Ansible NGINX Management Suite role or specific commit
    0.2.0

  • Version of Ansible
    2.15.0

  • Version of Jinja2 (if you are using any templating capability)

  • Target deployment platform
    AWS EC2 RH 7 instance

Additional context

Add any other context about the problem here.

Cleaning NGINX Management Suite repository after installation prevents nms-nap-compiler manual install

Describe the bug

After installing NGINX Management Suite on Debian/Ubuntu the file /etc/apt/sources.list.d/nms.list is removed through tasks/nms/remove-certs.yaml together with the NGINX license certificate and key. This makes it impossible to find & install nms-nap-compiler-*.

To reproduce

Steps to reproduce the behavior:

  1. Deploy the Ansible NGINX Management Suite role using playbook.yml
  2. Run apt-cache search nms-nap-compiler
  3. No packages are found

Expected behavior

After installing NGINX Management Suite using this role it should be possible to apt-get install the nms-nap-compiler module without having to recreate /etc/apt/sources.list.d/nms.list

Your environment

  • Ansible NGINX Management Suite role 0.3.0
  • Version of Ansible: ansible [core 2.12.10]
  • Target deployment platform: Ubuntu 20.04

Additional context

One potential improvement might be having the ability to specifiy one or more nms-nap-compiler versions to be installed, directly in the playbook.

Support 'uninstall' type

The role is able to install nms. Now we need the ability to uninstall. As of now, it is about 1/2 done.

Need:

  1. uninstall needs to be functional
  2. Tests need to be in place

Documentation Update

Describe the bug

Update README to walk through the following:

  1. Section for creating your own playbook, an example.
  • Update the license file path
  1. Elaborate on usage of the "latest edge"
  2. Provide an example inventory file in README
  3. Need to say you've done SSH Key Exchange

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.