Created
September 8, 2017 10:55
-
-
Save jfrancoa/5f66ba89da9e42256b4db2217b6ab962 to your computer and use it in GitHub Desktop.
Ansible playbook to disable multiple systemd services
This file contains hidden or 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
--- | |
- hosts: 127.0.0.1 | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Check if swift-storage services are deployed | |
command: systemctl is-enabled --quiet "{{ item }}" | |
register: swift_services_enabled | |
ignore_errors: true | |
with_items: | |
- openstack-swift-account-auditor | |
- openstack-swift-account-reaper | |
- openstack-swift-account-replicator | |
- openstack-swift-account | |
- openstack-swift-container-auditor | |
- openstack-swift-container-replicator | |
- openstack-swift-container-updater | |
- openstack-swift-container | |
- openstack-swift-object-auditor | |
- openstack-swift-object-expirer | |
- openstack-swift-object-replicator | |
- openstack-swift-object-updater | |
- openstack-swift-object | |
- debug: | |
var: swift_services_enabled | |
- name: Check that services are running | |
command: systemctl is-active --quiet "{{ item.item }}" | |
with_items: "{{ swift_services_enabled.results }}" | |
when: item.rc == 0 | |
- name: Stop and disable swift storage services | |
service: name={{ item.item }} state=stopped enabled=no | |
with_items: "{{ swift_services_enabled.results }}" | |
when: item.rc == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment