fixing service fail with systemd

This commit is contained in:
deimosfr 2015-02-25 08:57:36 +01:00
parent 6633edc0c5
commit edd9915a1a
4 changed files with 41 additions and 0 deletions

10
files/mongodb.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=An object/document-oriented database
Documentation=man:mongod(1)
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --config /etc/mongodb.conf
[Install]
WantedBy=multi-user.target

View File

@ -8,3 +8,6 @@
- name: mongodb-mms-automation-agent restart
service: name=mongodb-mms-automation-agent state=restarted
- name: reload systemd
shell: systemctl daemon-reload

View File

@ -13,9 +13,18 @@
template: src=logrotate.conf.j2 dest=/etc/logrotate.d/mongodb.conf
when: mongodb_logrotate
#- name: reload systemd
# shell: systemctl daemon-reload
# when: systemd.stat.exists == true
# changed_when: false
- name: ensure mongodb started and enabled
service: name={{ mongodb_daemon_name }} state=started enabled=yes
- name: wait MongoDB port is listening
wait_for: host="{{ mongodb_conf_bind_ip }}"port="{{ mongodb_conf_port }}" delay=5 state=started
when: systemd.stat.exists == true
- include: auth_initialization.yml
when: mongodb_conf_auth

View File

@ -2,6 +2,22 @@
- include_vars: "{{ansible_distribution}}.yml"
- name: Check if systemd is present
stat: path=/lib/systemd/system/
register: systemd
- name: Add systemd configuration if present
copy: src=mongodb.service dest=/lib/systemd/system/mongodb.service owner=root group=root mode=0640
when: systemd.stat.exists == true
- name: Add symlink for systemd
file: src=/lib/systemd/system/mongodb.service dest=/etc/systemd/system/multi-user.target.wants/mongodb.service state=link
when: systemd.stat.exists == true
notify: reload systemd
- meta: flush_handlers
when: systemd.stat.exists == true
- name: Add APT key
apt_key: url=http://docs.mongodb.org/10gen-gpg-key.asc id=7F0CEB10
when: '"mongodb-org" in mongodb_package'
@ -12,6 +28,9 @@
- name: Install MongoDB package
apt: pkg={{mongodb_package}} state=present
notify: reload systemd
- meta: flush_handlers
- name: Install additional packages
apt: pkg={{item}}