Refactor nodepool service

Allow the user to override the service settings and add unit tests.

Change-Id: I2d9409d210015a202f33eca970d02be137617de7
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2015-12-12 14:33:28 -05:00
parent 0bbbb72620
commit b08a112351
8 changed files with 61 additions and 10 deletions

View File

@ -59,3 +59,8 @@ nodepool_install_method: git
nodepool_pip_name: nodepool
nodepool_pip_version:
# tasks/service.yaml
nodepool_file_nodepool_service_group: root
nodepool_file_nodepool_service_mode: "0644"
nodepool_file_nodepool_service_owner: root

View File

@ -12,12 +12,30 @@
# License for the specific language governing permissions and limitations
# under the License.
---
- name: Define nodepool_file_nodepool_service_dest.
set_fact:
nodepool_file_nodepool_service_dest: "{{ __nodepool_file_nodepool_service_dest }}"
when: nodepool_file_nodepool_service_dest is not defined
- name: Define nodepool_file_nodepool_service_src.
set_fact:
nodepool_file_nodepool_service_src: "{{ __nodepool_file_nodepool_service_src }}"
when: nodepool_file_nodepool_service_src is not defined
- include: service/debian.yaml
when: ansible_os_family == 'Debian'
- include: service/redhat.yaml
when: ansible_os_family == 'RedHat'
- name: Copy services scripts into place.
copy:
dest: "{{ nodepool_file_nodepool_service_dest }}"
group: "{{ nodepool_file_nodepool_service_group }}"
mode: "{{ nodepool_file_nodepool_service_mode }}"
owner: "{{ nodepool_file_nodepool_service_owner }}"
src: "{{ nodepool_file_nodepool_service_src }}"
- name: Enable nodepool service.
service:
enabled: yes

View File

@ -12,11 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
---
- name: Copy upstart file into place.
copy:
dest: /etc/init
src: ../../files/etc/init/nodepool.conf
- name: Copy default file into place.
copy:
dest: /etc/default/nodepool

View File

@ -12,11 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
---
- name: Copy systemd file into place.
copy:
dest: /etc/systemd/system
src: ../../files/nodepool.service
- name: Copy sysconfig file into place.
copy:
dest: /etc/sysconfig/nodepool

View File

@ -105,3 +105,35 @@
that:
- nodepool_git_dest_stat.stat.exists
- nodepool_git_dest_stat.stat.isdir
- name: Register /etc/init/nodepool.conf
stat:
path: /etc/init/nodepool.conf
register: debian_nodepool_service_stat
when: ansible_os_family == 'Debian'
- name: Assert debian_nodepool_service_stat tests.
assert:
that:
- debian_nodepool_service_stat.stat.exists
- debian_nodepool_service_stat.stat.isreg
- debian_nodepool_service_stat.stat.pw_name == 'root'
- debian_nodepool_service_stat.stat.gr_name == 'root'
- debian_nodepool_service_stat.stat.mode == '0644'
when: ansible_os_family == 'Debian'
- name: Register /etc/systemd/system/nodepool.service
stat:
path: /etc/systemd/system/nodepool.service
register: redhat_nodepool_service_stat
when: ansible_os_family == 'RedHat'
- name: Assert redhat_nodepool_service_stat tests.
assert:
that:
- redhat_nodepool_service_stat.stat.exists
- redhat_nodepool_service_stat.stat.isreg
- redhat_nodepool_service_stat.stat.pw_name == 'root'
- redhat_nodepool_service_stat.stat.gr_name == 'root'
- redhat_nodepool_service_stat.stat.mode == '0644'
when: ansible_os_family == 'RedHat'

View File

@ -32,3 +32,6 @@ __nodepool_build_depends:
- python-dev
- python-pip
- zlib1g-dev
__nodepool_file_nodepool_service_dest: /etc/init/nodepool.conf
__nodepool_file_nodepool_service_src: ../files/etc/init/nodepool.conf

View File

@ -23,3 +23,6 @@ __nodepool_build_depends:
- python-devel
- python-pip
- zlib-devel
__nodepool_file_nodepool_service_dest: /etc/systemd/system/nodepool.service
__nodepool_file_nodepool_service_src: ../files/etc/systemd/system/nodepool.service