Skip to content

Commit 35389e7

Browse files
richmnatoscott
authored andcommitted
feat: support for ostree systems
Feature: Allow running and testing the role with ostree managed nodes. Reason: We have users who want to use the role to manage ostree systems. Result: Users can use the role to manage ostree managed nodes. Add dependency on `ansible.posix` which provides the `rhel_rpm_ostree` package manager. When using the `package:` module, add `use:` to force the use of the ostree package manager on ostree systems, and `omit` if not. Signed-off-by: Rich Megginson <[email protected]>
1 parent 630e87e commit 35389e7

File tree

11 files changed

+146
-17
lines changed

11 files changed

+146
-17
lines changed

galaxy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ build_ignore:
4646
- tests
4747
- tox.ini
4848

49-
dependencies: {}
49+
dependencies:
50+
ansible.posix: '*' # for rpm-ostree

roles/bpftrace/tasks/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
when: item is file
1313
# yamllint enable rule:line-length
1414

15+
- name: Determine if system is ostree and set flag
16+
when: not __ansible_pcp_is_ostree is defined
17+
block:
18+
- name: Check if system is ostree
19+
stat:
20+
path: /run/ostree-booted
21+
register: __ostree_booted_stat
22+
23+
- name: Set flag to indicate system is ostree
24+
set_fact:
25+
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
26+
1527
- name: Establish bpftrace package names
1628
set_fact:
1729
__bpftrace_packages_extra: "{{ __bpftrace_packages +
@@ -32,6 +44,8 @@
3244
package:
3345
name: "{{ __bpftrace_packages_extra }}"
3446
state: present
47+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
48+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
3549
when: __bpftrace_packages_extra | d([])
3650

3751
- name: Extract allowed bpftrace user accounts

roles/elasticsearch/tasks/main.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
when: item is file
1313
# yamllint enable rule:line-length
1414

15+
- name: Determine if system is ostree and set flag
16+
when: not __ansible_pcp_is_ostree is defined
17+
block:
18+
- name: Check if system is ostree
19+
stat:
20+
path: /run/ostree-booted
21+
register: __ostree_booted_stat
22+
23+
- name: Set flag to indicate system is ostree
24+
set_fact:
25+
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
26+
1527
- name: Establish Elasticsearch metrics package names
1628
set_fact:
1729
__elasticsearch_packages_extra: "{{ __elasticsearch_packages_extra +
@@ -32,6 +44,8 @@
3244
package:
3345
name: "{{ __elasticsearch_packages_extra }}"
3446
state: present
47+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
48+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
3549
when: __elasticsearch_packages_extra | d([])
3650

3751
- name: Ensure PCP Elasticsearch agent configuration directory exists
@@ -51,16 +65,9 @@
5165
- elasticsearch_metrics_provider == 'pcp'
5266
- elasticsearch_agent | d(false) | bool
5367

54-
- name: Check if system is ostree
55-
stat:
56-
path: "{{ ostree_booted_file }}"
57-
vars:
58-
ostree_booted_file: /run/ostree-booted
59-
register: __ostree_booted_stat
60-
6168
- name: Ensure correct service path for ostree systems
6269
when:
63-
- __ostree_booted_stat.stat.exists
70+
- __ansible_pcp_is_ostree | d(false)
6471
- __elasticsearch_service_path != "/etc/systemd/system"
6572
set_fact:
6673
__elasticsearch_service_path: /etc/systemd/system

roles/grafana/tasks/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,24 @@
1212
when: item is file
1313
# yamllint enable rule:line-length
1414

15+
- name: Determine if system is ostree and set flag
16+
when: not __ansible_pcp_is_ostree is defined
17+
block:
18+
- name: Check if system is ostree
19+
stat:
20+
path: /run/ostree-booted
21+
register: __ostree_booted_stat
22+
23+
- name: Set flag to indicate system is ostree
24+
set_fact:
25+
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
26+
1527
- name: Install Grafana packages
1628
package:
1729
name: "{{ __grafana_packages + __grafana_packages_extra }}"
1830
state: present
31+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
32+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
1933

2034
- name: Get package facts now that Grafana is installed
2135
package_facts:

roles/mssql/tasks/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
when: item is file
1313
# yamllint enable rule:line-length
1414

15+
- name: Determine if system is ostree and set flag
16+
when: not __ansible_pcp_is_ostree is defined
17+
block:
18+
- name: Check if system is ostree
19+
stat:
20+
path: /run/ostree-booted
21+
register: __ostree_booted_stat
22+
23+
- name: Set flag to indicate system is ostree
24+
set_fact:
25+
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
26+
1527
- name: Establish SQL Server metrics package names
1628
set_fact:
1729
__mssql_packages_extra: "{{ __mssql_packages_pcp }}"
@@ -21,6 +33,8 @@
2133
package:
2234
name: "{{ __mssql_packages_extra }}"
2335
state: present
36+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
37+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
2438
when: __mssql_packages_extra | d([])
2539

2640
- name: Ensure PCP SQL Server agent configuration directory exists

roles/pcp/tasks/main.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,31 @@
1212
when: item is file
1313
# yamllint enable rule:line-length
1414

15+
- name: Determine if system is ostree and set flag
16+
when: not __ansible_pcp_is_ostree is defined
17+
block:
18+
- name: Check if system is ostree
19+
stat:
20+
path: /run/ostree-booted
21+
register: __ostree_booted_stat
22+
23+
- name: Set flag to indicate system is ostree
24+
set_fact:
25+
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
26+
1527
- name: Install Performance Co-Pilot packages
1628
package:
1729
name: "{{ __pcp_packages + __pcp_packages_extra + pcp_optional_packages }}"
1830
state: present
31+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
32+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
1933

2034
- name: Install authentication packages
2135
package:
2236
name: "{{ __pcp_sasl_packages }}"
2337
state: present
38+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
39+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
2440
when:
2541
- __pcp_sasl_packages | d([])
2642
- pcp_accounts | d({})

roles/postfix/tasks/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
when: item is file
1313
# yamllint enable rule:line-length
1414

15+
- name: Determine if system is ostree and set flag
16+
when: not __ansible_pcp_is_ostree is defined
17+
block:
18+
- name: Check if system is ostree
19+
stat:
20+
path: /run/ostree-booted
21+
register: __ostree_booted_stat
22+
23+
- name: Set flag to indicate system is ostree
24+
set_fact:
25+
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
26+
1527
- name: Establish Postfix metrics package names
1628
set_fact:
1729
__postfix_packages_extra: "{{ __postfix_packages_pcp }}"
@@ -21,4 +33,6 @@
2133
package:
2234
name: "{{ __postfix_packages_extra }}"
2335
state: present
36+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
37+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
2438
when: __postfix_packages_extra | d([])

roles/redis/tasks/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,24 @@
1212
when: item is file
1313
# yamllint enable rule:line-length
1414

15+
- name: Determine if system is ostree and set flag
16+
when: not __ansible_pcp_is_ostree is defined
17+
block:
18+
- name: Check if system is ostree
19+
stat:
20+
path: /run/ostree-booted
21+
register: __ostree_booted_stat
22+
23+
- name: Set flag to indicate system is ostree
24+
set_fact:
25+
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
26+
1527
- name: Install Redis packages
1628
package:
1729
name: "{{ __redis_packages + __redis_packages_extra }}"
1830
state: present
31+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
32+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
1933

2034
- name: Ensure Redis configuration directory exists
2135
file:

roles/spark/tasks/main.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
when: item is file
1313
# yamllint enable rule:line-length
1414

15+
- name: Determine if system is ostree and set flag
16+
when: not __ansible_pcp_is_ostree is defined
17+
block:
18+
- name: Check if system is ostree
19+
stat:
20+
path: /run/ostree-booted
21+
register: __ostree_booted_stat
22+
23+
- name: Set flag to indicate system is ostree
24+
set_fact:
25+
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
26+
1527
- name: Establish Spark metrics package names
1628
set_fact:
1729
__spark_packages_extra: "{{ __spark_packages_extra +
@@ -32,6 +44,8 @@
3244
package:
3345
name: "{{ __spark_packages_extra }}"
3446
state: present
47+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
48+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
3549
when: __spark_packages_extra | d([])
3650

3751
- name: Ensure PCP OpenMetrics agent is configured for Spark
@@ -52,16 +66,9 @@
5266
- spark_metrics_provider == 'pcp'
5367
- spark_metrics_agent | d(false) | bool
5468

55-
- name: Check if system is ostree
56-
stat:
57-
path: "{{ ostree_booted_file }}"
58-
vars:
59-
ostree_booted_file: /run/ostree-booted
60-
register: __ostree_booted_stat
61-
6269
- name: Ensure correct service path for ostree systems
6370
when:
64-
- __ostree_booted_stat.stat.exists
71+
- __ansible_pcp_is_ostree | d(false)
6572
- __spark_service_path != "/etc/systemd/system"
6673
set_fact:
6774
__spark_service_path: /etc/systemd/system

tests/tests_verify_mssql.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,24 @@
2020
- name: Save state of services
2121
import_tasks: get_services_state.yml
2222

23+
- name: Determine if system is ostree and set flag
24+
when: not __ansible_pcp_is_ostree is defined
25+
block:
26+
- name: Check if system is ostree
27+
stat:
28+
path: /run/ostree-booted
29+
register: __ostree_booted_stat
30+
31+
- name: Set flag to indicate system is ostree
32+
set_fact:
33+
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
34+
2335
- name: Ensure python3-pyodbc is installed
2436
package:
2537
name: python3-pyodbc
2638
state: present
39+
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
40+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
2741

2842
tasks:
2943
- name: Check MSSQL functionality

0 commit comments

Comments
 (0)