geerlingguy / ansible-role-redis

Ansible Role - Redis
https://galaxy.ansible.com/geerlingguy/redis/
MIT License
254 stars 197 forks source link

Does not enable as a systemd service #37

Closed methodmain closed 4 years ago

methodmain commented 5 years ago

Using this role I found that systemctl status redis-server would return

redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-12-05 19:35:24 UTC; 2min 39s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
 Main PID: 13355 (redis-server)
    Tasks: 4 (limit: 4383)
   CGroup: /system.slice/redis-server.service
           `-13355 /usr/bin/redis-server 127.0.0.1:6379

In tasks/main.yml there is the line service: "name={{ redis_daemon }} state=started enabled=yes" which should enable the service.

To get around this I added my own task after the geerlingguy.redis role completed:

- name: enable redis-server
  systemd:
    name: redis-server
    enabled: yes
  when: ansible_service_mgr == 'systemd'

which effectively didn't change anything. I finally tried:

- name: Ensure redis-server is enabled
  shell: systemctl enable redis-server
  register: enable_result
  when: ansible_service_mgr == 'systemd'
  changed_when: "'Created symlink' in enable_result.stderr" 

this did work with the output:

changed: [voltserv-app-04] => {
    "changed": true,
    "cmd": "systemctl enable redis-server",
    "delta": "0:00:00.500761",
    "end": "2018-12-05 19:03:05.330731",
    "invocation": {
        "module_args": {
            "_raw_params": "systemctl enable redis-server",
            "_uses_shell": true,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "warn": true
        }
    },
    "rc": 0,
    "start": "2018-12-05 19:03:04.829970",
    "stderr": "Synchronizing state of redis-server.service with SysV service script with /lib/systemd/systemd-sysv-install.\nExecuting: /lib/systemd/systemd-sysv-install enable redis-server\nCreated symlink /etc/systemd/system/redis.service -> /lib/systemd/system/redis-server.service.",
    "stderr_lines": [
        "Synchronizing state of redis-server.service with SysV service script with /lib/systemd/systemd-sysv-install.",
        "Executing: /lib/systemd/systemd-sysv-install enable redis-server",
        "Created symlink /etc/systemd/system/redis.service -> /lib/systemd/system/redis-server.service."
    ],
    "stdout": "",
    "stdout_lines": []
}changed: [voltserv-app-04] => {
    "changed": true,
    "cmd": "systemctl enable redis-server",
    "delta": "0:00:00.500761",
    "end": "2018-12-05 19:03:05.330731",
    "invocation": {
        "module_args": {
            "_raw_params": "systemctl enable redis-server",
            "_uses_shell": true,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "warn": true
        }
    },
    "rc": 0,
    "start": "2018-12-05 19:03:04.829970",
    "stderr": "Synchronizing state of redis-server.service with SysV service script with /lib/systemd/systemd-sysv-install.\nExecuting: /lib/systemd/systemd-sysv-install enable redis-server\nCreated symlink /etc/systemd/system/redis.service -> /lib/systemd/system/redis-server.service.",
    "stderr_lines": [
        "Synchronizing state of redis-server.service with SysV service script with /lib/systemd/systemd-sysv-install.",
        "Executing: /lib/systemd/systemd-sysv-install enable redis-server",
        "Created symlink /etc/systemd/system/redis.service -> /lib/systemd/system/redis-server.service."
    ],
    "stdout": "",
    "stdout_lines": []
}

I would expect that the service should be enabled to start with, and also that the initial attempt to enable would work. I wouldn't rule out user error but figured I'd submitted an issue anyway. Let me know if I can provide any other info.

- Ansible version: ansible 2.6.2
  config file = None
  configured module search path = [u'/Users/greggbailey/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.15 (default, Jun 17 2018, 12:46:58) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
- Machine running ansible playbook: macOS Mojave 10.14.1
- Linux version: NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
- geerlinguy.redis: 1.6.0 (also experienced issue on 1.5.1)
stale[bot] commented 4 years ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

stale[bot] commented 4 years ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.