Skip to content

Commit

Permalink
try again
Browse files Browse the repository at this point in the history
  • Loading branch information
richm committed Apr 8, 2024
1 parent 57cc9e9 commit 5ec24c1
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tests/tests_second_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,26 @@
- "' -f/etc/ssh/sshd_config' not in service_inst.content | b64decode"
- "' -f/etc/ssh2/sshd_config' in service_inst.content | b64decode"

- name: Get service facts
ansible.builtin.service_facts:

- name: Stop second service
ansible.builtin.service:
name: sshd2
state: stopped
enabled: false
register: __sshd2_service
failed_when:
- __sshd2_service is failed
- not "Could not find the requested service sshd2" in __msg
- not "Service is in unknown state" in __msg
when: "'sshd2' in __sshd_services"
vars:
__msg: "{{ '' if not __sshd2_service is defined
else __sshd2_service.stderr if 'stderr' in __sshd2_service
else __sshd2_service.msg if 'msg' in __sshd2_service
else '' }}"
__sshd_services: "{{ ansible_facts.services.values() |
selectattr('name', 'defined') |
selectattr('status', 'defined') |
rejectattr('status', 'match', '^not-found$') |
rejectattr('status', 'match', '^masked$') |
rejectattr('status', 'match', '^failed$') |
map(attribute='name') |
map('regex_replace', '[.]service.*$', '') |
map('regex_replace', '@$', '') |
unique | list }}"

- name: Remove second service
ansible.builtin.file:
Expand Down

0 comments on commit 5ec24c1

Please sign in to comment.