-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Fix using the default network manager in reset.yml #11678
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -414,12 +414,31 @@ | |||||
- network | ||||||
|
||||||
- name: Reset | Restart network | ||||||
service: | ||||||
name: "{{ reset_restart_network_service_name }}" | ||||||
state: restarted | ||||||
become: true | ||||||
vars: | ||||||
network_services: | ||||||
- NetworkManager | ||||||
- systemd-networkd | ||||||
- networking | ||||||
- network | ||||||
when: | ||||||
- ansible_os_family not in ["Flatcar", "Flatcar Container Linux by Kinvolk"] | ||||||
- reset_restart_network | bool | ||||||
tags: | ||||||
- services | ||||||
- network | ||||||
block: | ||||||
- name: Gather active network services | ||||||
# noqa command-instead-of-module | ||||||
command: systemctl is-active {{ item }} | ||||||
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. You can use the systemd module with only name to check for status. systemd:
name: <service>
register: service
service.status.ActivateState == 'active' |
||||||
loop: "{{ network_services }}" | ||||||
register: service_status | ||||||
changed_when: false | ||||||
ignore_errors: true | ||||||
|
||||||
- name: Restart active network services | ||||||
systemd: | ||||||
name: "{{ item.item }}" | ||||||
state: restarted | ||||||
loop: "{{ service_status.results }}" | ||||||
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.
Suggested change
+ drop the when 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. Hello @KubeKyrie Would you please check it? 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. Ok, thanks, I will check it. |
||||||
when: item.stdout == "active" |
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.
drop this var and just specify the list directly in the loop below.