summaryrefslogtreecommitdiffstats
path: root/roles/etcd
diff options
context:
space:
mode:
authorRussell Teague <rteague@redhat.com>2016-11-18 14:26:02 -0500
committerRussell Teague <rteague@redhat.com>2016-11-28 11:11:44 -0500
commitec9c22ca6a376b7d1139a384dcb78f3f5bb5b607 (patch)
treea8c3897b9765b9b6dc02582a851b704be8f0828e /roles/etcd
parentb45db4c7e0b278623f7531cee50127aa24686139 (diff)
downloadopenshift-ec9c22ca6a376b7d1139a384dcb78f3f5bb5b607.tar.gz
openshift-ec9c22ca6a376b7d1139a384dcb78f3f5bb5b607.tar.bz2
openshift-ec9c22ca6a376b7d1139a384dcb78f3f5bb5b607.tar.xz
openshift-ec9c22ca6a376b7d1139a384dcb78f3f5bb5b607.zip
Refactored to use Ansible systemd module
* Ansible systemd module used in place of service module * Refactored command tasks which are no longer necessary * Applying rules from openshift-ansible Best Practices Guide
Diffstat (limited to 'roles/etcd')
-rw-r--r--roles/etcd/README.md3
-rw-r--r--roles/etcd/handlers/main.yml2
-rw-r--r--roles/etcd/meta/main.yml2
-rw-r--r--roles/etcd/tasks/main.yml32
4 files changed, 15 insertions, 24 deletions
diff --git a/roles/etcd/README.md b/roles/etcd/README.md
index 329a926c0..c936dbabc 100644
--- a/roles/etcd/README.md
+++ b/roles/etcd/README.md
@@ -6,7 +6,8 @@ Configures an etcd cluster for an arbitrary number of hosts
Requirements
------------
-This role assumes it's being deployed on a RHEL/Fedora based host with package
+* Ansible 2.2
+* This role assumes it's being deployed on a RHEL/Fedora based host with package
named 'etcd' available via yum or dnf (conditionally).
Role Variables
diff --git a/roles/etcd/handlers/main.yml b/roles/etcd/handlers/main.yml
index e00e1cac4..95076b19e 100644
--- a/roles/etcd/handlers/main.yml
+++ b/roles/etcd/handlers/main.yml
@@ -1,5 +1,5 @@
---
- name: restart etcd
- service: name={{ etcd_service }} state=restarted
+ systemd: name={{ etcd_service }} state=restarted
when: not (etcd_service_status_changed | default(false) | bool)
diff --git a/roles/etcd/meta/main.yml b/roles/etcd/meta/main.yml
index cfd72dfbc..532f9e313 100644
--- a/roles/etcd/meta/main.yml
+++ b/roles/etcd/meta/main.yml
@@ -7,7 +7,7 @@ galaxy_info:
description: etcd management
company: Red Hat, Inc.
license: Apache License, Version 2.0
- min_ansible_version: 2.1
+ min_ansible_version: 2.2
platforms:
- name: EL
versions:
diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml
index 7b61e9b73..41f25be70 100644
--- a/roles/etcd/tasks/main.yml
+++ b/roles/etcd/tasks/main.yml
@@ -20,36 +20,25 @@
template:
dest: "/etc/systemd/system/etcd_container.service"
src: etcd.docker.service
- register: install_etcd_result
when: etcd_is_containerized | bool
-- name: Ensure etcd datadir exists
- when: etcd_is_containerized | bool
+- name: Ensure etcd datadir exists when containerized
file:
path: "{{ etcd_data_dir }}"
state: directory
mode: 0700
-
-- name: Check for etcd service presence
- command: systemctl show etcd.service
- register: etcd_show
- changed_when: false
- failed_when: false
+ when: etcd_is_containerized | bool
- name: Disable system etcd when containerized
- when: etcd_is_containerized | bool and etcd_show.rc == 0 and 'LoadState=not-found' not in etcd_show.stdout
- service:
+ systemd:
name: etcd
state: stopped
enabled: no
-
-- name: Mask system etcd when containerized
- when: etcd_is_containerized | bool and etcd_show.rc == 0 and 'LoadState=not-found' not in etcd_show.stdout
- command: systemctl mask etcd
-
-- name: Reload systemd units
- command: systemctl daemon-reload
- when: etcd_is_containerized | bool and ( install_etcd_result | changed )
+ masked: yes
+ daemon_reload: yes
+ when: etcd_is_containerized | bool
+ register: task_result
+ failed_when: "task_result|failed and 'could not' not in task_result.msg|lower"
- name: Validate permissions on the config dir
file:
@@ -68,7 +57,7 @@
- restart etcd
- name: Enable etcd
- service:
+ systemd:
name: "{{ etcd_service }}"
state: started
enabled: yes
@@ -77,5 +66,6 @@
- include: etcdctl.yml
when: openshift_etcd_etcdctl_profile | default(true) | bool
-- set_fact:
+- name: Set fact etcd_service_status_changed
+ set_fact:
etcd_service_status_changed: "{{ start_result | changed }}"