Skip to content

Commit 406260d

Browse files
committed
Add choice of service user (1/2)
Password in case of non-service account still needed
1 parent 670df12 commit 406260d

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

roles/ifw/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ Table of contents:
5656
Components installed but not present within this list will be removed.
5757
Default: `[ { name: "plugins", state: "present" }, { name: "agent", state: "present" } ]`
5858

59+
- `ifw_icinga2_user: string`
60+
The user Icinga 2 runs as. This user is only used if `ifw_jea_managed_user=false`.
61+
Default: `NT Authority\NetworkService`
62+
5963
- `ifw_icinga2_ca_host: string`
6064
The Ansible inventory hostname of your Icinga 2 CA host (master).
6165
This variable is used to sign the certificate for your Windows host using delegated tasks.
@@ -112,6 +116,7 @@ Table of contents:
112116
Whether to install the Icinga for Windows JEA profile.
113117
If `ifw_jea_managed_user=false`, the JEA will profile will be created and registered.
114118
If `ifw_jea_managed_user=true`, the service user 'icinga' will also be created to run Icinga for Windows as.
119+
If both `ifw_jea_install=true` and `ifw_jea_managed_user=true`, `ifw_icinga2_user` will essentially be ignored.
115120
[Read more about Icinga for Windows and JEA](https://icinga.com/docs/icinga-for-windows/latest/doc/130-JEA/01-JEA-Profiles/).
116121
Default: `true`
117122

roles/ifw/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ ifw_components:
1414
- name: "agent"
1515
state: "present"
1616

17+
ifw_icinga2_user: "NT Authority\\NetworkService"
1718
ifw_icinga2_ca_host:
1819
ifw_connection_direction: "fromagent"
1920
ifw_force_newcert: false
2021
ifw_icinga2_cn: "{{ inventory_hostname }}"
2122
ifw_icinga2_port: 5665
2223
ifw_icinga2_global_zones: []
2324

25+
2426
ifw_jea_install: true
2527
ifw_jea_managed_user: true
2628

roles/ifw/meta/argument_specs.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ argument_specs:
8989
- The version of the component to be installed / removed.
9090
type: str
9191
required: false
92+
ifw_icinga2_user:
93+
description:
94+
- The user Icinga 2 runs as. This user is only used if O(ifw_jea_managed_user=false).
95+
type: str
96+
required: false
97+
default: "NT Authority\\NetworkService"
9298
ifw_icinga2_ca_host:
9399
description:
94100
- The Ansible C(inventory_hostname) of your Icinga 2 CA host (master).
@@ -168,8 +174,9 @@ argument_specs:
168174
ifw_jea_install:
169175
description:
170176
- Whether to install the Icinga for Windows JEA profile.
171-
If O(ifw_jea_managed_user=false), the JEA will profile will be created and registered.
177+
If O(ifw_jea_managed_user=false), the JEA will profile will be created and registered for the user running Icinga for Windows (O(ifw_icinga2_user) by default).
172178
If O(ifw_jea_managed_user=true), the service user 'icinga' will also be created to run Icinga for Windows as.
179+
If both O(ifw_jea_install=true) and O(ifw_jea_managed_user=true), O(ifw_icinga2_user) will essentially be ignored.
173180
L(Read more about Icinga for Windows and JEA, https://icinga.com/docs/icinga-for-windows/latest/doc/130-JEA/01-JEA-Profiles/).
174181
type: bool
175182
required: false

roles/ifw/tasks/configure_icinga2.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
_current_ca_server: "{{ _framework_config_live['IfW-CAServer']['Values'][0] | default(none) }}"
103103
_current_global_zones: "{{ _framework_config_live['IfW-CustomZones']['Values'] }}"
104104
_current_cn: "{{ _framework_config_live['IfW-CustomHostname']['Values'][0] }}"
105+
_current_agent_user: "{{ _framework_config_live['IfW-AgentUser']['Values'][0] }}"
105106
_current_port: "{{ _framework_config_live['IfW-Port']['Values'][0] | default(none) }}"
106107
_current_parent_zone: "{{ _framework_config_live['IfW-ParentZone']['Values'][0] | default(none) }}"
107108
_current_parents: "{{ _framework_config_live['IfW-ParentNodes']['Values'] }}"
@@ -122,6 +123,7 @@
122123
- (_current_ca_server | default(true, true)) == (_ifw_ca_server)
123124
- _current_global_zones == ifw_icinga2_global_zones
124125
- _current_cn == ifw_icinga2_cn
126+
- _current_agent_user == ifw_icinga2_user
125127
- (_current_port | int) == (ifw_icinga2_port | int)
126128
- _current_parent_zone == ifw_icinga2_parent_zone
127129
- _current_parents == (ifw_icinga2_parents | map(attribute='cn'))

roles/ifw/templates/windows/icinga_install_command.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
"{{ ifw_icinga2_cn }}"
9191
]
9292
},
93+
"IfW-AgentUser": {
94+
"Values": [
95+
{# Ensure single backslash becomes double backslash. InstallCommand fails otherwise #}
96+
"{{ ifw_icinga2_user | replace('\\', '\\\\') }}"
97+
]
98+
},
9399
"IfW-InstallApiChecks": {
94100
{# 0 -> Don't install IfW Api Check Forwarder #}
95101
"Selection": "0"

0 commit comments

Comments
 (0)