Ansible Role linuxfabrik.lfops.curaline¶
This role installs and configures the curaLINE Client (cdr-client) of Swisscom, which exchanges files with the curaLINE Document Routing (CDR) service of the Swiss healthcare system. It unpacks the client from the Swisscom download page, configures its connectors and runs it as the systemd service swisscom-schweiz-ag-cdr-client.service, either under a system account of its own or under an existing account such as hnet of an H-Net SecureClient installation.
Available in the next LFOps release.
How the Role Behaves¶
- The client is downloaded on the Ansible controller (
delegate_to: 'localhost') into/tmpand uploaded to the target, so targets without Internet access can still be provisioned. The controller needs outbound HTTPS access tocdr.health.swisscom.ch. The target needs it only for the client to do its work. - The client comes with its own Java runtime and is only published for
linux-amd64. The role aborts on other architectures. - The installed version is recorded in
/usr/lib/swisscom-schweiz-ag/cdr-client/.ansible-version. When it differs fromcuraline__version, the role removes/usr/lib/swisscom-schweiz-ag/cdr-client, unpacks the new version and restarts the service. The configuration lives in/etc/swisscom-schweiz-ag/cdr-clientand survives the update. - The service runs as
curaline__userandcuraline__group. If they do not exist, the role creates them as a system user and group. An existing user is taken over as it is: the role changes neither its UID, home, shell nor comment, so other software using the account keeps working. - The installation directory belongs to
curaline__user, as with the Debian package of the client. The role hands it over recursively whencuraline__userorcuraline__groupchange. - The systemd unit is modelled on the one of the Debian package, with the same name, user and group names and directories, but with a static user instead of a dynamic one. The client gets
/var/lib/swisscom-schweiz-ag/cdr-clientas its$HOME, whatever the home ofcuraline__useris, and writes its log to/var/log/swisscom-schweiz-ag/cdr-client. The unit runs the client sandboxed: it may only write to its installation, configuration, state, cache and log directories and to the folders of its connectors. - The folders of the connectors (
source-folder,target-folder,source-archive-folder) andcuraline__local_folderare created forcuraline__userif they do not exist yet. Existing folders keep their owner, mode and content, so they must already be writable bycuraline__user. Parent directories are created owned byroot. The client creates the subfolders below them, such aserror, itself. - Files must be written to a source folder under a temporary name and renamed to
*.xmlwhen complete, and must be readable bycuraline__user. The client uploads a file that is still being written in fragments, and retries an unreadable file forever as*.upload. - The files in
/etc/swisscom-schweiz-ag/cdr-clientare re-rendered on every run (a timestamped backup is kept), so manual edits are overwritten. This includes the client secret inapplication-customer.yaml. - With
curaline__renew_credential: truethe client renews the secret and rewritesapplication-customer.yamlitself. The next run of the role restores the old secret and renewal time from the inventory, so the client immediately tries to renew again with a secret that is no longer valid, and its login is denied. Keep it atfalseand renew the secret by hand. - The role does not manage the firewall. The client only makes outgoing connections, and its management ports
8191and8193listen on127.0.0.1. - On the Red Hat family with SELinux, the role sets the
bin_tfile context on/usr/lib/swisscom-schweiz-ag/cdr-client/bin, so that systemd may execute the client from/usr/lib. - The client downloads a document into
curaline__local_folderand then moves it to the target folder, so the file keeps the SELinux label ofcuraline__local_folder. If a confined service reads the target folder, for example the/data/xmltree of an H-Net SecureClient installation labelleduser_home_t, putcuraline__local_folderbelow the same tree, such as/data/xml/cdr-inflight.
Known Limitations¶
- Only
x86_64hosts are supported. - Hosts with the Debian package of the client are not supported. Remove the package before running the role.
- The role does not configure the proxy of the client.
- The role manages one client per host.
Requirements¶
- Credentials for the curaLINE Document Routing service: the client ID and the client secret of the application registered for this client, and the connector ID(s) of the practice or institution.
- Outbound HTTPS access from the Ansible controller to
cdr.health.swisscom.ch, and from the target tocdr.health.swisscom.chandlogin.microsoftonline.com.
Replacing the H-Net SecureClient¶
To take over the data folders of an H-Net SecureClient installation (typically /data/xml/{inbox,outbox,archive} and their -test counterparts, owned by hnet:hnet), run the client under the same account:
curaline__group: 'hnet'
curaline__user: 'hnet'
The role leaves the hnet account, /home/hnet, /var/hnet and the SELinux setup of the SecureClient (user_home_t on /data/xml, the HnetSecureService policy module) untouched, and does not manage hnet-securesvc.service.
Warning: Do not run both clients on the same folders. The SecureClient and the curaLINE Client would both pick up the files in the outbox, and documents could be sent twice or get lost. Stop and disable the SecureClient (systemctl disable --now hnet-securesvc.service) before the curaLINE Client is started for the first time, or deploy the role with curaline__service_enabled: false and curaline__service_state: 'stopped' until the switch-over.
Post-Installation Steps¶
- Check the connection to the service:
curl --silent http://127.0.0.1:8193/actuator/healthno longer reports"authN": {"status": "DENIED"}once the credentials are accepted.
Tags¶
curaline
- Installs the required packages.
- Creates the user and group of the service if they do not exist, and the missing folders of the connectors.
- Installs the client.
- Deploys the configuration files and the systemd unit.
- Sets the SELinux file context of the client (Red Hat family with SELinux).
- Ensures the service is in the desired state.
- Triggers: swisscom-schweiz-ag-cdr-client.service restart.
curaline:configure
- Deploys the configuration files and the systemd unit.
- Sets the SELinux file context of the client (Red Hat family with SELinux).
- Triggers: swisscom-schweiz-ag-cdr-client.service restart.
curaline:state
- Manages the service state (start, stop, enable, disable).
- Triggers: none.
curaline:update
- Installs the client in the version of
curaline__version, if a different version or none is installed, and hands the installation directory tocuraline__user. - Sets the SELinux file context of the client (Red Hat family with SELinux).
- Triggers: swisscom-schweiz-ag-cdr-client.service restart.
Mandatory Role Variables¶
curaline__client_id
- The client ID of the application registered for this client.
- Type: String.
curaline__client_secret
- The client secret that belongs to the client ID.
- Type: String.
curaline__connectors__host_var / curaline__connectors__group_var
- The connectors of the client. At least one must be present. Items are identified by the combination of
connector-idandmode, so the same connector can run intestandproductionmode at once. - Type: List of dictionaries.
- Default:
[] -
Subkeys:
-
connector-id:- Mandatory. The ID of the connector, assigned by Swisscom.
- Type: Number.
-
mode:- Mandatory.
productionortest. - Type: String.
- Mandatory.
-
content-type:- Mandatory. The content type of the documents.
- Type: String.
-
source-folder:- Mandatory. The folder the client uploads documents from.
- Type: String.
-
target-folder:- Mandatory. The folder the client puts downloaded documents into.
- Type: String.
-
source-archive-enabled:- Optional. Whether the client moves uploaded documents to
source-archive-folder. - Type: Bool.
- Optional. Whether the client moves uploaded documents to
-
source-archive-folder:- Optional. The folder for uploaded documents.
- Type: String.
-
state:- Optional.
presentorabsent. A connector set toabsentis removed from the configuration, and its folders are not created. - Type: String.
- Default:
'present'
- Optional.
-
Any other key the client knows is written to the configuration as it is.
-
curaline__version
- The version of the curaLINE Client to install.
- Type: String.
Example:
# mandatory
curaline__client_id: 'linuxfabrik'
curaline__client_secret: 'linuxfabrik'
curaline__connectors__host_var:
- connector-id: 40000
mode: 'test'
content-type: 'application/forumdatenaustausch+xml;charset=UTF-8'
source-folder: '/data/xml/outbox-test/XMLDatenforum'
target-folder: '/data/xml/inbox-test/XMLDatenforum'
source-archive-enabled: true
source-archive-folder: '/data/xml/archive-test'
curaline__version: '6.2.1'
Optional Role Variables¶
curaline__cdr_api_base_path
- Base path of the curaLINE document API.
- Type: String.
- Default:
'api/documents'
curaline__cdr_api_host
- Host name of the curaLINE API.
- Type: String.
- Default:
'cdr.health.swisscom.ch'
curaline__cdr_api_port
- Port of the curaLINE document API.
- Type: Number.
- Default:
443
curaline__cdr_api_scheme
- Scheme of the curaLINE document API. One of
http,https. - Type: String.
- Default:
'https'
curaline__credential_api_base_path
- Base path of the curaLINE credential API.
- Type: String.
- Default:
'api/client-credentials'
curaline__credential_api_host
- Host name of the curaLINE credential API.
- Type: String.
- Default:
{{ curaline__cdr_api_host }}
curaline__credential_api_port
- Port of the curaLINE credential API.
- Type: Number.
- Default:
{{ curaline__cdr_api_port }}
curaline__credential_api_scheme
- Scheme of the curaLINE credential API. One of
http,https. - Type: String.
- Default:
{{ curaline__cdr_api_scheme }}
curaline__file_busy_test_strategy
- How the client decides that a file in a source folder is completely written.
file_size_changedsamples the file size,never_busytakes every file as finished,always_busynever uploads. - Type: String. One of
always_busy,file_size_changed,never_busy. - Default:
'file_size_changed'
curaline__file_synchronization_enabled
- Whether the client uploads and downloads files.
- Type: Bool.
- Default:
true
curaline__group
- Group of the service. Created as a system group if it does not exist. Set it to
'hnet'to take over an H-Net SecureClient installation, see "Replacing the H-Net SecureClient". - Type: String.
- Default:
'swisscom-schweiz-ag-cdr-client'
curaline__idp_endpoint
- The OAuth2 token endpoint of the identity provider.
- Type: String.
- Default:
'https://login.microsoftonline.com/{{ curaline__tenant_id }}/oauth2/v2.0/token'
curaline__last_credential_renewal_time
- When the client credential was last renewed. A time in the past makes the client renew it on start, if
curaline__renew_credentialis enabled. - Type: String.
- Default:
'1970-01-01T00:00:00Z'
curaline__local_folder
- Folder for temporary downloads.
- Type: String.
- Default:
'/data/cdr-inflight' - Deviates from the upstream default
${java.io.tmpdir}: the unit runs the client withPrivateTmp=yes, so its/tmpis private to the service and is emptied on every stop and restart, which would lose the documents that are being downloaded.
curaline__renew_credential
- Whether the client renews its client secret on its own, see "How the Role Behaves".
- Type: Bool.
- Default:
false - Deviates from the upstream default
true: with it the client rewritesapplication-customer.yamlon its own, which the next run of the role would undo.
curaline__schedule_delay
- Interval between two upload and download runs, as an ISO 8601 duration.
- Type: String.
- Default:
'PT10M'
curaline__scope
- The OAuth2 scope of the token request.
- Type: String.
- Default:
'https://identity.health.swisscom.ch/CdrApi/.default'
curaline__service_enabled
- Enables or disables the service, analogous to
systemctl enable/disable --now. - Type: Bool.
- Default:
true
curaline__service_state
- Changes the state of the service, analogous to
systemctl start/stop/restart. - Type: String. One of
restarted,started,stopped. - Default:
'started'
curaline__tenant_id
- The Entra ID tenant that issues the tokens. The default is the tenant of Swisscom, which the client ships with.
- Type: String.
- Default:
'70b434db-eccb-4280-95dc-1e59220aca55'
curaline__user
- User of the service. Created as a system user without a login shell if it does not exist. An existing user is not modified. Set it to
'hnet'to take over an H-Net SecureClient installation, see "Replacing the H-Net SecureClient". - Type: String.
- Default:
'swisscom-schweiz-ag-cdr-client'
Example:
# optional
curaline__cdr_api_base_path: 'api/documents'
curaline__cdr_api_host: 'cdr.health.swisscom.ch'
curaline__cdr_api_port: 443
curaline__cdr_api_scheme: 'https'
curaline__credential_api_base_path: 'api/client-credentials'
curaline__file_busy_test_strategy: 'file_size_changed'
curaline__file_synchronization_enabled: true
curaline__group: 'hnet'
curaline__local_folder: '/data/cdr-inflight'
curaline__renew_credential: false
curaline__schedule_delay: 'PT10M'
curaline__service_enabled: true
curaline__service_state: 'started'
curaline__user: 'hnet'
Troubleshooting¶
curl http://127.0.0.1:8193/actuator/health reports "authN": {"status": "DENIED"}
- The identity provider rejects the credentials. Check
curaline__client_id,curaline__client_secretandcuraline__tenant_id. The client keeps running and retries, the reason is in/var/log/swisscom-schweiz-ag/cdr-client/cdr-client-service.log.
The service fails with status=226/NAMESPACE
- A path in
ReadWritePaths=of the unit does not exist, typically a folder of a connector that was removed by hand, or one on a network share that is not mounted. Run the role again to recreate missing folders, or mount the share before the service starts.
The run aborts with curaline__version must look like "6.2.1"
- Set
curaline__versionto a release listed on the curaLINE download page.
The run aborts with At least one connector must be present ... or Connector ... must set content-type, source-folder and target-folder
- Give the host at least one connector in
curaline__connectors__host_varorcuraline__connectors__group_var, with all mandatory subkeys set.