-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add win_service task to the role #4
Merged
DanielWeeber
merged 1 commit into
DanielWeeber:master
from
brandonmcclure:bmcclure/ServiceControls
Apr 16, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
--- | ||
- name: Check that the service variable values are sane | ||
assert: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this assert to try to provide some user validation if they pass in strange combinations. I am sure this will not cover all possible combinations that could break the |
||
that: | ||
- windows_exporter_state != 'started' and windows_exporter_start_mode != 'disabled' | ||
fail_msg: "You cannot manage the service with the windows_exporter_state and windows_exporter_start_mode settings" | ||
- name: Check current windows_exporter version. | ||
win_command: "{{ windows_exporter_bin_path }} --version" | ||
failed_when: false | ||
|
@@ -27,10 +32,20 @@ | |
state: present | ||
enabled: yes | ||
notify: restart windows_exporter | ||
|
||
- name: windows_exporter service settings | ||
ansible.windows.win_service: | ||
name: windows_exporter | ||
start_mode: "{{ windows_exporter_start_mode }}" | ||
state: "{{ windows_exporter_state }}" | ||
- name: Verify windows_exporter is responding to requests. | ||
win_uri: | ||
url: http://localhost:9182/ | ||
return_content: true | ||
register: metrics_output | ||
failed_when: "'Metrics' not in metrics_output.content" | ||
when: > | ||
windows_exporter_start_mode <> 'disabled' or | ||
windows_exporter_start_mode <> 'manual' and ( | ||
windows_exporter_state == 'started' OR WINDOWS_EXPORTER_STATE == 'restarted' | ||
) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched the default state to started so that the role becomes idempotent. With restarted every time I run a play with this role, my services get restarted which is not desirable during normal operation imo.