{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/36585","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/36585/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/36585/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/36585/events","html_url":"https://github.com/ansible/ansible/issues/36585","id":299403262,"number":36585,"title":"systemd module - Could not find the requested service XXX: host","user":{"login":"keltik85","id":13469004,"avatar_url":"https://avatars1.githubusercontent.com/u/13469004?v=4","gravatar_id":"","url":"https://api.github.com/users/keltik85","html_url":"https://github.com/keltik85","followers_url":"https://api.github.com/users/keltik85/followers","following_url":"https://api.github.com/users/keltik85/following{/other_user}","gists_url":"https://api.github.com/users/keltik85/gists{/gist_id}","starred_url":"https://api.github.com/users/keltik85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keltik85/subscriptions","organizations_url":"https://api.github.com/users/keltik85/orgs","repos_url":"https://api.github.com/users/keltik85/repos","events_url":"https://api.github.com/users/keltik85/events{/privacy}","received_events_url":"https://api.github.com/users/keltik85/received_events","type":"User","site_admin":false},"labels":[{"id":562292166,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.4","name":"affects_2.4","color":"ededed","default":false},{"id":785271699,"url":"https://api.github.com/repos/ansible/ansible/labels/bug","name":"bug","color":"fbca04","default":true},{"id":496359346,"url":"https://api.github.com/repos/ansible/ansible/labels/module","name":"module","color":"1d76db","default":false},{"id":636352796,"url":"https://api.github.com/repos/ansible/ansible/labels/support:core","name":"support:core","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-02-22T15:46:03Z","updated_at":"2018-05-24T13:11:26Z","closed_at":null,"author_association":"NONE","body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n\r\n##### COMPONENT NAME\r\nsystemd\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible 2.4.3.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = [u'/home/atekin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/lib/python2.7/dist-packages/ansible\r\n  executable location = /usr/bin/ansible\r\n  python version = 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]\r\n```\r\n\r\n##### CONFIGURATION\r\n\r\n##### OS / ENVIRONMENT\r\n**Host:**\r\n```\r\nmy-user@my-host:~/vagrant_arch_linux_cluster$ cat /etc/*release\r\nDISTRIB_ID=Ubuntu\r\nDISTRIB_RELEASE=17.10\r\nDISTRIB_CODENAME=artful\r\nDISTRIB_DESCRIPTION=\"Ubuntu 17.10\"\r\nNAME=\"Ubuntu\"\r\nVERSION=\"17.10 (Artful Aardvark)\"\r\nID=ubuntu\r\nID_LIKE=debian\r\nPRETTY_NAME=\"Ubuntu 17.10\"\r\nVERSION_ID=\"17.10\"\r\nHOME_URL=\"https://www.ubuntu.com/\"\r\nSUPPORT_URL=\"https://help.ubuntu.com/\"\r\nBUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"\r\nPRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\r\nVERSION_CODENAME=artful\r\nUBUNTU_CODENAME=artful\r\n```\r\n\r\n**Guest:**\r\n```\r\nroot@arch-1:/home/vagrant#\r\nArch Linux release\r\nLSB_VERSION=1.4\r\nDISTRIB_ID=Arch\r\nDISTRIB_RELEASE=rolling\r\nDISTRIB_DESCRIPTION=\"Arch Linux\"\r\nNAME=\"Arch Linux\"\r\nPRETTY_NAME=\"Arch Linux\"\r\nID=arch\r\nID_LIKE=archlinux\r\nANSI_COLOR=\"0;36\"\r\nHOME_URL=\"https://www.archlinux.org/\"\r\nSUPPORT_URL=\"https://bbs.archlinux.org/\"\r\nBUG_REPORT_URL=\"https://bugs.archlinux.org/\"\r\n```\r\n\r\n##### SUMMARY\r\nAnsible thinks that there is no `mongod` service at all on the guest-machine and does not restart the service, although the service is only disabled, as this shell command strongly suggests:\r\n```\r\nroot@arch-1:/home/vagrant# systemctl list-unit-files | grep mongo\r\nmongodb.service                            disabled\r\n```\r\n\r\n##### STEPS TO REPRODUCE\r\n1. Configure stuff in the ansible hosts file `/etc/ansible/hosts`:\r\n```\r\n[arch-linux-cluster:vars]\r\nansible_ssh_private_key_file = /home/my-user/some_private_key\r\nansible_ssh_user=some-ssh-user\r\nansible_ssh_pass=some-ssh-user\r\nansible_become=yes\r\nansible_become_method=su\r\nansible_become_exe=\"sudo su -\"\r\n\r\n[arch-linux-cluster]\r\n192.168.178.69\r\n192.168.178.70\r\n192.168.178.71\r\n192.168.178.72\r\n192.168.178.73\r\n```\r\n2. Created a `configure.yml` file:\r\n```yaml\r\n---\r\n- hosts: arch-linux-cluster\r\n  tasks:\r\n    - pacman:\r\n        update_cache: yes\r\n        upgrade: yes\r\n    - pacman:\r\n        name: mongodb\r\n        state: present\r\n    - lineinfile:\r\n        path: /etc/mongodb.conf\r\n        line: \"replSet = rs0\"\r\n      when: ansible_hostname == \"arch-1\"\r\n    - systemd:\r\n        name: mongod\r\n        state: restarted\r\n      when: ansible_hostname == \"arch-1\"\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nAnsible should restart the disabled service and do not tell me that there is no service at all, which is incorrect and misleading. In fact, Ansible installed the service in a previous task already.\r\n\r\n##### ACTUAL RESULTS\r\n```\r\nmy-user@my-host:~/vagrant_arch_linux_cluster$ ansible-playbook -vv configuration.yml\r\nansible-playbook 2.4.3.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = [u'/home/my-user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/lib/python2.7/dist-packages/ansible\r\n  executable location = /usr/bin/ansible-playbook\r\n  python version = 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]\r\nUsing /etc/ansible/ansible.cfg as config file\r\n\r\nPLAYBOOK: configuration.yml ******************************************************************************************************************\r\n1 plays in configuration.yml\r\n\r\nPLAY [arch-linux-cluster] ********************************************************************************************************************\r\n\r\nTASK [Gathering Facts] ***********************************************************************************************************************\r\nok: [192.168.178.72]\r\nok: [192.168.178.73]\r\nok: [192.168.178.71]\r\nok: [192.168.178.69]\r\nok: [192.168.178.70]\r\nMETA: ran handlers\r\n\r\nTASK [pacman] ********************************************************************************************************************************\r\ntask path: /home/my-user/vagrant_arch_linux_cluster/configuration.yml:4\r\nok: [192.168.178.71] => {\"changed\": false, \"msg\": \"Nothing to upgrade\", \"packages\": []}\r\nok: [192.168.178.70] => {\"changed\": false, \"msg\": \"Nothing to upgrade\", \"packages\": []}\r\nok: [192.168.178.72] => {\"changed\": false, \"msg\": \"Nothing to upgrade\", \"packages\": []}\r\nok: [192.168.178.69] => {\"changed\": false, \"msg\": \"Nothing to upgrade\", \"packages\": []}\r\nok: [192.168.178.73] => {\"changed\": false, \"msg\": \"Nothing to upgrade\", \"packages\": []}\r\n\r\nTASK [pacman] ********************************************************************************************************************************\r\ntask path: /home/my-user/vagrant_arch_linux_cluster/configuration.yml:7\r\nok: [192.168.178.71] => {\"changed\": false, \"msg\": \"package(s) already installed. \"}\r\nok: [192.168.178.72] => {\"changed\": false, \"msg\": \"package(s) already installed. \"}\r\nok: [192.168.178.73] => {\"changed\": false, \"msg\": \"package(s) already installed. \"}\r\nok: [192.168.178.70] => {\"changed\": false, \"msg\": \"package(s) already installed. \"}\r\nok: [192.168.178.69] => {\"changed\": false, \"msg\": \"package(s) already installed. \"}\r\n\r\nTASK [lineinfile] ****************************************************************************************************************************\r\ntask path: /home/my-user/vagrant_arch_linux_cluster/configuration.yml:10\r\nskipping: [192.168.178.70] => {\"changed\": false, \"skip_reason\": \"Conditional result was False\"}\r\nskipping: [192.168.178.71] => {\"changed\": false, \"skip_reason\": \"Conditional result was False\"}\r\nskipping: [192.168.178.72] => {\"changed\": false, \"skip_reason\": \"Conditional result was False\"}\r\nskipping: [192.168.178.73] => {\"changed\": false, \"skip_reason\": \"Conditional result was False\"}\r\nok: [192.168.178.69] => {\"backup\": \"\", \"changed\": false, \"msg\": \"\"}\r\n\r\nTASK [systemd] *******************************************************************************************************************************\r\ntask path: /home/my-user/vagrant_arch_linux_cluster/configuration.yml:14\r\nskipping: [192.168.178.70] => {\"changed\": false, \"skip_reason\": \"Conditional result was False\"}\r\nskipping: [192.168.178.71] => {\"changed\": false, \"skip_reason\": \"Conditional result was False\"}\r\nskipping: [192.168.178.72] => {\"changed\": false, \"skip_reason\": \"Conditional result was False\"}\r\nskipping: [192.168.178.73] => {\"changed\": false, \"skip_reason\": \"Conditional result was False\"}\r\nfatal: [192.168.178.69]: FAILED! => {\"changed\": false, \"msg\": \"Could not find the requested service mongod: host\"}\r\nMETA: ran handlers\r\nMETA: ran handlers\r\n\tto retry, use: --limit @/home/my-user/vagrant_arch_linux_cluster/configuration.retry\r\n\r\nPLAY RECAP ***********************************************************************************************************************************\r\n192.168.178.69             : ok=4    changed=0    unreachable=0    failed=1   \r\n192.168.178.70             : ok=3    changed=0    unreachable=0    failed=0   \r\n192.168.178.71             : ok=3    changed=0    unreachable=0    failed=0   \r\n192.168.178.72             : ok=3    changed=0    unreachable=0    failed=0   \r\n192.168.178.73             : ok=3    changed=0    unreachable=0    failed=0\r\n```\r\nIn Short: `fatal: [192.168.178.69]: FAILED! => {\"changed\": false, \"msg\": \"Could not find the requested service mongod: host\"`"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/391709025","html_url":"https://github.com/ansible/ansible/issues/36585#issuecomment-391709025","issue_url":"https://api.github.com/repos/ansible/ansible/issues/36585","id":391709025,"user":{"login":"eaglemoor","id":1461295,"avatar_url":"https://avatars0.githubusercontent.com/u/1461295?v=4","gravatar_id":"","url":"https://api.github.com/users/eaglemoor","html_url":"https://github.com/eaglemoor","followers_url":"https://api.github.com/users/eaglemoor/followers","following_url":"https://api.github.com/users/eaglemoor/following{/other_user}","gists_url":"https://api.github.com/users/eaglemoor/gists{/gist_id}","starred_url":"https://api.github.com/users/eaglemoor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eaglemoor/subscriptions","organizations_url":"https://api.github.com/users/eaglemoor/orgs","repos_url":"https://api.github.com/users/eaglemoor/repos","events_url":"https://api.github.com/users/eaglemoor/events{/privacy}","received_events_url":"https://api.github.com/users/eaglemoor/received_events","type":"User","site_admin":false},"created_at":"2018-05-24T13:11:26Z","updated_at":"2018-05-24T13:11:26Z","author_association":"NONE","body":"Catch this error on centos 7. Without Docker."}}
{"actor":{"display_login":"eaglemoor"}}