Skip to content

Instantly share code, notes, and snippets.

@wahello
Forked from jfrancoa/swift-disable.yaml
Created February 22, 2021 03:25
Show Gist options
  • Save wahello/c8c59f6523fe974dced068aea02d390c to your computer and use it in GitHub Desktop.
Save wahello/c8c59f6523fe974dced068aea02d390c to your computer and use it in GitHub Desktop.
Ansible playbook to disable multiple systemd services
---
- 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