Add HA (load balancing) support

This patch add support for configuring proteccio to use
more than one HSM.  When more than one HSM is provided
the proteccio client is configured for High Availability (HA).

This patch changes the format of the variables and should
be released as a new major version. (e.g. 1.0.0).

Change-Id: Ib9989ee72a67f71275e31b966bff7673072fb3f8
This commit is contained in:
Douglas Mendizábal 2019-12-19 16:19:37 +00:00
parent 90bb6f6ec8
commit 5069751256
8 changed files with 86 additions and 24 deletions

View File

@ -22,20 +22,35 @@ Role Variables
* - atos_client_iso_location * - atos_client_iso_location
- None - None
- Full URL where a copy of ATOS Client ISO can be downloaded. - Full URL where a copy of ATOS Client ISO can be downloaded.
* - atos_hsm_ip_address
- None
- IPv4 address for the ATOS HSM.
* - atos_client_cert_location * - atos_client_cert_location
- None - None
- Full URL where the client certificate can be downloaded. - Full URL where the client certificate can be downloaded.
* - atos_client_key_location * - atos_client_key_location
- None - None
- Full URL where the client key can be downloaded. - Full URL where the client key can be downloaded.
* - atos_server_cert_location * - atos_hsms
- None - None
- Full URL where the server certificate can be downloaded. - List of one or more HSM devices.
Requirements Requirements
------------ ------------
- ansible >= 2.4 - ansible >= 2.4
Usage
-----
You'll need to set up a temporary HTTP server somewhere that is accessible
to the node where this role will be applied. The HTTP server should serve
the following:
- ATOS Client Software ISO file.
- HSM Server Certificate file(s).
- HSM Client Certificate file.
- HSM Client Key file associated with the Client Certificate.
Due to the sensitive nature of the Certificate and Key files, you should
use TLS encryption and username and passwords to access the HTTP server.
Use the hostname and user/password for your HTTP server for the full URL values
that need to be set for this role. See `vars.yaml.example`.

5
handlers/main.yaml Normal file
View File

@ -0,0 +1,5 @@
---
- name: legacy vars warning
debug:
msg: "WARNING: Using legacy atos_server_cert_location and atos_hsm_ip_address
variables. Please udpate your vars file."

View File

@ -0,0 +1,12 @@
---
features:
- |
This version adds support for using more than one ATOS HSM in High
Availability mode. There is a new variable `atos_hsms` that accepts
a list of HSM IP addresses and associated Certificates. See
`vars.yaml.sample` for an example.
deprecations:
- |
Two variables have been deprecated: `atos_hsm_ip_address` and
`atos_server_cert_location`. You should use the new `atos_hsms` list
to specify these values instead. See `vars.yaml.sample` for an example.

View File

@ -3,12 +3,12 @@ name = ansible-role-atos-hsm
summary = ansible-role-atos-hsm - Ansible role to configure ATOS HSM clients. summary = ansible-role-atos-hsm - Ansible role to configure ATOS HSM clients.
description-file = description-file =
README.rst README.rst
author = TripleO Team author = OpenStack Barbican Team
author-email = alee@redhat.com author-email = alee@redhat.com
home-page = https://github.com/dmend/ansible-role-atos-hsm home-page = https://opendev.org/openstack/ansible-role-atos-hsm
classifier = classifier =
License :: OSI Approved :: Apache Software License License :: OSI Approved :: Apache Software License
Development Status :: 4 - Beta Development Status :: 5 - Production/Stable
Intended Audience :: Developers Intended Audience :: Developers
Intended Audience :: System Administrators Intended Audience :: System Administrators
Intended Audience :: Information Technology Intended Audience :: Information Technology

View File

@ -32,21 +32,20 @@
"Press the <Enter> key to exit the installation program": "\n" "Press the <Enter> key to exit the installation program": "\n"
when: not atos_client.stat.exists when: not atos_client.stat.exists
- name: create proteccio.rc - name: allow using legacy variables for backwards compatibility
copy: set_fact:
dest: /etc/proteccio/proteccio.rc args:
content: | atos_hsms:
[PROTECCIO] - name: Legacy variables HSM
IPaddr={{ atos_hsm_ip_address }} server_cert_location: "{{ atos_server_cert_location }}"
SSL=1 ip: "{{ atos_hsm_ip_address }}"
SrvCert=server_cert.crt when: atos_hsms is not defined and atos_hsm_ip_address is defined
notify: legacy vars warning
[CLIENT] - name: create proteccio.rc
Mode=0 template:
LoggingLevel=7 src: proteccio.rc.j2
LogFile=proteccio.log dest: /etc/proteccio/proteccio.rc
ClntKey=proteccio_client.key
ClntCert=proteccio_client.crt
- name: Get the client cert - name: Get the client cert
get_url: get_url:
@ -62,9 +61,10 @@
- name: Get the server cert - name: Get the server cert
get_url: get_url:
url: "{{ atos_server_cert_location }}" url: "{{ item.server_cert_location }}"
dest: /etc/proteccio/server_cert.crt dest: "/etc/proteccio/{{ item.ip | replace('.', '_') }}.CRT"
force: no force: no
loop: "{{ atos_hsms }}"
- name: run nethsmstatus to confirm connection # noqa 301 - name: run nethsmstatus to confirm connection # noqa 301
command: nethsmstatus command: nethsmstatus

17
templates/proteccio.rc.j2 Normal file
View File

@ -0,0 +1,17 @@
{% for item in atos_hsms %}
[PROTECCIO]
IPaddr={{ item.ip }}
SSL=1
SrvCert={{ item.ip | replace('.', '_') }}.CRT
{% endfor %}
[CLIENT]
{% if atos_hsms|length > 1 %}
Mode=2
{% else %}
Mode=0
{% endif %}
LoggingLevel=7
LogFile=/var/log/barbican/atos.log
ClntKey=proteccio_client.key
ClntCert=proteccio_client.crt

View File

@ -1 +1,2 @@
ansible-lint ansible-lint
reno

12
vars.yaml.sample Normal file
View File

@ -0,0 +1,12 @@
---
atos_client_iso_name: "ClientSoftwareISO-1.X.iso"
atos_client_iso_location: "https://user:PASSWORD@intranet.example/hsm/client/ClientSoftwareISO-1.X.iso"
atos_client_cert_location: "https://user:PASSWORD@intranet.example/hsm/client/client_cert.crt"
atos_client_key_location: "https://user:PASSWORD@intranet.example/hsm/client/client_key.key"
atos_hsms:
- name: "MyHSM 1"
server_cert_location: "https://user:PASSWORD@intranet.example/hsm/server/myhsm_1.crt"
ip: 192.168.1.1
- name: "MyHSM 2"
server_cert_location: "https://user:PASSWORD@intranet.example/hsm/server/myhsm_2.crt"
ip: 192.168.1.2