postgres (9.6 on debian 9) service should be enabled according to the version it is installed otherwise you would probably get an "empty" service template for systemd
the ansible role defines a handler to restart postgresql however it is using the postgres_daemon var which is set incorrectly therefore giving false indication for database service restart, see below:
RUNNING HANDLER [geerlingguy.postgresql : restart postgresql] ********************************************************************************************************************************
[WARNING]: Ignoring "sleep" as it is not used in "systemd"
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/system/systemd.py
<192.168.33.50> ESTABLISH SSH CONNECTION FOR USER: vagrant
<192.168.33.50> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansib
le/cp/673d2d4c12 192.168.33.50 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-dpuxjcyqgnwvajepusmhaselfsacbhku; /usr/bin/python'"'"'"'"'"'"'"'"' && sl
eep 0'"'"''
**<192.168.33.50> (0, '\n{"status": {"ExecStart": "{ path=/bin/true ; argv[]=/bin/true ; ignore_errors=no ; start_time=[Tue 2017-08-08 11:01:49 UTC] ; stop_time=[Tue 2017-08-08 11:01:49 UTC] ;**
pid=9860 ; code=exited ; status=0 }", "TimeoutStopUSec": "1min 30s", "RuntimeDirectoryMode": "0755", "GuessMainPID": "yes", "ActiveExitTimestamp": "Tue 2017-08-08 11:01:46 UTC", "ExecMainCo
de": "1", "PropagatesReloadTo": "[email protected]", "ExecMainPID": "9860", "LimitSIGPENDING": "1878", "MemoryHigh": "18446744073709551615", "OOMScoreAdjust": "0", "LoadState": "lo
aded", "UID": "4294967295", "ProtectHome": "no", "RuntimeMaxUSec": "infinity", "TTYVHangup": "no", "WatchdogTimestampMonotonic": "0", "LimitMSGQUEUESoft": "819200", "LimitSTACK": "1844674407
3709551615", "MemorySwapMax": "18446744073709551615", "ActiveEnterTimestampMonotonic": "1763252353", "StandardError": "inherit", "CanIsolate": "no", "LimitDATASoft": "18446744073709551615",
"GID": "4294967295", "CPUSchedulingPriority": "0", "KillSignal": "15", "LimitFSIZE": "18446744073709551615", "IgnoreOnIsolate": "no", "LimitCPU": "18446744073709551615", "AssertTimestamp": "
Tue 2017-08-08 11:01:49 UTC", "RemoveIPC": "no", "CPUUsageNSec": "18446744073709551615", "LimitNICESoft": "0", "LimitMEMLOCKSoft": "65536", "UnitFileState": "enabled", "NoNewPrivileges": "no
", "MemoryLimit": "18446744073709551615", "MemoryDenyWriteExecute": "no", "InvocationID": "24928b8fde164fa8987ff78cfc47eb01", "CanStart": "yes", "IOAccounting": "no", "JobTimeoutAction": "no
ne", "Before": "multi-user.target exim4.service shutdown.target", "LimitAS": "18446744073709551615", "SyslogLevel": "6", "RootDirectoryStartOnly": "no", "InactiveExitTimestampMonotonic": "17
63248168", "SendSIGHUP": "no", "TimeoutStartUSec": "infinity", "Type": "oneshot", "FailureAction": "none", "SameProcessGroup": "no", "LimitNPROC": "1878", "UMask": "0022", "NonBlocking": "no
", "DevicePolicy": "auto", "ProtectKernelTunables": "no", "ExecMainStartTimestamp": "Tue 2017-08-08 11:01:49 UTC", "LimitRSSSoft": "18446744073709551615", "CapabilityBoundingSet": "184467440
73709551615", "TTYReset": "no", "FileDescriptorStoreMax": "0", "RefuseManualStart": "no", "KillMode": "control-group", "SyslogLevelPrefix": "yes", "LimitRSS": "18446744073709551615", "LimitR
TPRIO": "0", "StartupCPUWeight": "18446744073709551615", "Delegate": "no", "MemoryMax": "18446744073709551615", "ExecReload": "{ path=/bin/true ; argv[]=/bin/true ; ignore_errors=no ; start_
time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }", "SyslogFacility": "3", "TasksCurrent": "18446744073709551615", "InactiveExitTimestamp": "Tue 2017-08-08 11:01:49 UTC", "Li
mitCORE": "18446744073709551615", "JobTimeoutUSec": "infinity", "TimerSlackNSec": "50000", "StateChangeTimestamp": "Tue 2017-08-08 11:01:49 UTC", "SubState": "exited", "CPUSchedulingResetOnF
ork": "no", "Result": "success", "CPUShares": "18446744073709551615", "LimitCORESoft": "0", "ConditionResult": "yes", "NFileDescriptorStore": "0", "LimitNOFILESoft": "1024", "TTYVTDisallocat
e": "no", "MainPID": "0", "StartupBlockIOWeight": "18446744073709551615", "ActiveEnterTimestamp": "Tue 2017-08-08 11:01:49 UTC", "FragmentPath": "/lib/systemd/system/postgresql.service", "Li
mitSIGPENDINGSoft": "1878", "ProtectControlGroups": "no", "StartupCPUShares": "18446744073709551615", "WatchdogUSec": "0", "ActiveState": "active", "Nice": "0", "LimitDATA": "184467440737095
51615", "UnitFilePreset": "enabled", "LimitNPROCSoft": "1878", "MemoryCurrent": "18446744073709551615", "LimitRTTIME": "18446744073709551615", "WantedBy": "multi-user.target", "SecureBits":
"0", "RestartUSec": "100ms", "ConditionTimestamp": "Tue 2017-08-08 11:01:49 UTC", "CPUAccounting": "no", "RemainAfterExit": "yes", "PrivateUsers": "no", "PrivateNetwork": "no", "StartupIOWei
ght": "18446744073709551615", "Restart": "no", "CPUSchedulingPolicy": "0", "LimitNOFILE": "4096", "SendSIGKILL": "yes", "StatusErrno": "0", "RefuseManualStop": "no", "SystemCallErrorNumber":
"0", "MemoryLow": "0", "Perpetual": "no", "IOWeight": "18446744073709551615", "LimitCPUSoft": "18446744073709551615", "TasksAccounting": "yes", "NeedDaemonReload": "no", "ExecMainExitTimest
amp": "Tue 2017-08-08 11:01:49 UTC", "InactiveEnterTimestamp": "Tue 2017-08-08 11:01:46 UTC", "StandardInput": "null", "AssertTimestampMonotonic": "1763247726", "DefaultDependencies": "yes",
"Requires": "sysinit.target system.slice", "UtmpMode": "init", "StateChangeTimestampMonotonic": "1763252353", "TasksMax": "4915", "CPUQuotaPerSecUSec": "infinity", "ExecMainStatus": "0", "L
imitMEMLOCK": "65536", "StopWhenUnneeded": "no", "LimitMSGQUEUE": "819200", "LimitRTPRIOSoft": "0", "LimitSTACKSoft": "8388608", "CPUWeight": "18446744073709551615", "AmbientCapabilities": "
0", "AllowIsolate": "no", "Slice": "system.slice", "ExecMainExitTimestampMonotonic": "1763252196", "ConsistsOf": "[email protected]", "LimitFSIZESoft": "18446744073709551615", "Sta
rtLimitIntervalSec": "10000000", "NotifyAccess": "none", "PermissionsStartOnly": "no", "BlockIOAccounting": "no", "CanStop": "yes", "PrivateTmp": "no", "OnFailureJobMode": "replace", "Assert
Result": "yes", "LimitLOCKS": "18446744073709551615", "ExecMainStartTimestampMonotonic": "1763248143", "StartLimitBurst": "5", "Wants": "[email protected]", "After": "systemd-journ
ald.socket system.slice basic.target [email protected] sysinit.target", "ProtectKernelModules": "no", "SyslogPriority": "30", "StartLimitAction": "none", "Conflicts": "shutdown.tar
get", "RestrictNamespace": "2114060288", "StandardOutput": "journal", "MountFlags": "0", "InactiveEnterTimestampMonotonic": "1760095277", "MemoryAccounting": "no", "IgnoreSIGPIPE": "yes", "T
ransient": "no", "IOScheduling": "0", "Description": "PostgreSQL RDBMS", "DynamicUser": "no", "ActiveExitTimestampMonotonic": "1760095277", "RestrictRealtime": "no", "CanReload": "yes", "Con
trolPID": "0", "LimitNICE": "0", "BlockIOWeight": "18446744073709551615", "LimitLOCKSSoft": "18446744073709551615", "LimitRTTIMESoft": "18446744073709551615", "Names": "postgresql.service",
"ProtectSystem": "no", "LimitASSoft": "18446744073709551615", "PrivateDevices": "no", "Id": "postgresql.service", "ConditionTimestampMonotonic": "1763247726"}, "invocation": {"module_args":
{"no_block": false, "name": "postgresql", "enabled": null, "daemon_reload": false, "state": "restarted", "user": false, "masked": null}}, "state": "started", "changed": true, "name": "postgr
esql"}\n', '')
changed: [postgresql001] => {
"changed": true,
"invocation": {
"module_args": {
"daemon_reload": false,
"enabled": null,
"masked": null,
"name": "postgresql",
"no_block": false,
"state": "restarted",
"user": false
}
},
"name": "postgresql",
"state": "started",
"status": {
"ActiveEnterTimestamp": "Tue 2017-08-08 11:01:49 UTC",
"ActiveEnterTimestampMonotonic": "1763252353",
"ActiveExitTimestamp": "Tue 2017-08-08 11:01:46 UTC",
"ActiveExitTimestampMonotonic": "1760095277",
"ActiveState": "active",
"After": "systemd-journald.socket system.slice basic.target [email protected] sysinit.target",
"AllowIsolate": "no",
"AmbientCapabilities": "0",
"AssertResult": "yes",
"AssertTimestamp": "Tue 2017-08-08 11:01:49 UTC",
"AssertTimestampMonotonic": "1763247726",
"Before": "multi-user.target exim4.service shutdown.target",
"BlockIOAccounting": "no",
"BlockIOWeight": "18446744073709551615",
"CPUAccounting": "no",
"CPUQuotaPerSecUSec": "infinity",
"CPUSchedulingPolicy": "0",
"CPUSchedulingPriority": "0",
"CPUSchedulingResetOnFork": "no",
"CPUShares": "18446744073709551615",
"CPUUsageNSec": "18446744073709551615",
"CPUWeight": "18446744073709551615",
"CanIsolate": "no",
"CanReload": "yes",
"CanStart": "yes",
"CanStop": "yes",
"CapabilityBoundingSet": "18446744073709551615",
"ConditionResult": "yes",
"ConditionTimestamp": "Tue 2017-08-08 11:01:49 UTC",
"ConditionTimestampMonotonic": "1763247726",
"Conflicts": "shutdown.target",
"ConsistsOf": "[email protected]",
"ControlPID": "0",
"DefaultDependencies": "yes",
"Delegate": "no",
"Description": "PostgreSQL RDBMS",
"DevicePolicy": "auto",
"DynamicUser": "no",
"ExecMainCode": "1",
"ExecMainExitTimestamp": "Tue 2017-08-08 11:01:49 UTC",
"ExecMainExitTimestampMonotonic": "1763252196",
"ExecMainPID": "9860",
"ExecMainStartTimestamp": "Tue 2017-08-08 11:01:49 UTC",
"ExecMainStartTimestampMonotonic": "1763248143",
"ExecMainStatus": "0",
"ExecReload": "{ path=/bin/true ; argv[]=/bin/true ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }",
"ExecStart": "{ path=/bin/true ; argv[]=/bin/true ; ignore_errors=no ; start_time=[Tue 2017-08-08 11:01:49 UTC] ; stop_time=[Tue 2017-08-08 11:01:49 UTC] ; pid=9860 ; code=exited ; s
tatus=0 }",
"FailureAction": "none",
"FileDescriptorStoreMax": "0",
"FragmentPath": "/lib/systemd/system/postgresql.service",
"GID": "4294967295",
"GuessMainPID": "yes",
"IOAccounting": "no",
"IOScheduling": "0",
"IOWeight": "18446744073709551615",
"Id": "postgresql.service",
"IgnoreOnIsolate": "no",
"IgnoreSIGPIPE": "yes",
"InactiveEnterTimestamp": "Tue 2017-08-08 11:01:46 UTC",
"InactiveEnterTimestampMonotonic": "1760095277",
"InactiveExitTimestamp": "Tue 2017-08-08 11:01:49 UTC",
"InactiveExitTimestampMonotonic": "1763248168",
"InvocationID": "24928b8fde164fa8987ff78cfc47eb01",
"JobTimeoutAction": "none",
"JobTimeoutUSec": "infinity",
"KillMode": "control-group",
"KillSignal": "15",
"LimitAS": "18446744073709551615",
"LimitASSoft": "18446744073709551615",
"LimitCORE": "18446744073709551615",
"LimitCORESoft": "0",
"LimitCPU": "18446744073709551615",
"LimitCPUSoft": "18446744073709551615",
"LimitDATA": "18446744073709551615",
"LimitDATASoft": "18446744073709551615",
"LimitFSIZE": "18446744073709551615",
"LimitFSIZESoft": "18446744073709551615",
"LimitLOCKS": "18446744073709551615",
"LimitLOCKSSoft": "18446744073709551615",
"LimitMEMLOCK": "65536",
"LimitMEMLOCKSoft": "65536",
"LimitMSGQUEUE": "819200",
"LimitMSGQUEUESoft": "819200",
"LimitNICE": "0",
"LimitNICESoft": "0",
"LimitNOFILE": "4096",
"LimitNOFILESoft": "1024",
"LimitNPROC": "1878",
"LimitNPROCSoft": "1878",
"LimitRSS": "18446744073709551615",
"LimitRSSSoft": "18446744073709551615",
"LimitRTPRIO": "0",
"LimitRTPRIOSoft": "0",
"LimitRTTIME": "18446744073709551615",
"LimitRTTIMESoft": "18446744073709551615",
"LimitSIGPENDING": "1878",
"LimitSIGPENDINGSoft": "1878",
"LimitSTACK": "18446744073709551615",
"LimitSTACKSoft": "8388608",
"LoadState": "loaded",
"MainPID": "0",
"MemoryAccounting": "no",
"MemoryCurrent": "18446744073709551615",
"MemoryDenyWriteExecute": "no",
"MemoryHigh": "18446744073709551615",
"MemoryLimit": "18446744073709551615",
"MemoryLow": "0",
"MemoryMax": "18446744073709551615",
"MemorySwapMax": "18446744073709551615",
"MountFlags": "0",
"NFileDescriptorStore": "0",
"Names": "postgresql.service",
"NeedDaemonReload": "no",
"Nice": "0",
"NoNewPrivileges": "no",
"NonBlocking": "no",
"NotifyAccess": "none",
"OOMScoreAdjust": "0",
"OnFailureJobMode": "replace",
"PermissionsStartOnly": "no",
"Perpetual": "no",
"PrivateDevices": "no",
"PrivateNetwork": "no",
"PrivateTmp": "no",
"PrivateUsers": "no",
"PropagatesReloadTo": "[email protected]",
"ProtectControlGroups": "no",
"ProtectHome": "no",
"ProtectKernelModules": "no",
"ProtectKernelTunables": "no",
"ProtectSystem": "no",
"RefuseManualStart": "no",
"RefuseManualStop": "no",
"RemainAfterExit": "yes",
"RemoveIPC": "no",
"Requires": "sysinit.target system.slice",
"Restart": "no",
"RestartUSec": "100ms",
"RestrictNamespace": "2114060288",
"RestrictRealtime": "no",
"Result": "success",
"RootDirectoryStartOnly": "no",
"RuntimeDirectoryMode": "0755",
"RuntimeMaxUSec": "infinity",
"SameProcessGroup": "no",
"SecureBits": "0",
"SendSIGHUP": "no",
"SendSIGKILL": "yes",
"Slice": "system.slice",
"StandardError": "inherit",
"StandardInput": "null",
"StandardOutput": "journal",
"StartLimitAction": "none",
"StartLimitBurst": "5",
"StartLimitIntervalSec": "10000000",
"StartupBlockIOWeight": "18446744073709551615",
"StartupCPUShares": "18446744073709551615",
"StartupCPUWeight": "18446744073709551615",
"StartupIOWeight": "18446744073709551615",
"StateChangeTimestamp": "Tue 2017-08-08 11:01:49 UTC",
"StateChangeTimestampMonotonic": "1763252353",
"StatusErrno": "0",
"StopWhenUnneeded": "no",
"SubState": "exited",
"SyslogFacility": "3",
"SyslogLevel": "6",
"SyslogLevelPrefix": "yes",
"SyslogPriority": "30",
"SystemCallErrorNumber": "0",
"TTYReset": "no",
"TTYVHangup": "no",
"TTYVTDisallocate": "no",
"TasksAccounting": "yes",
"TasksCurrent": "18446744073709551615",
"TasksMax": "4915",
"TimeoutStartUSec": "infinity",
"TimeoutStopUSec": "1min 30s",
"TimerSlackNSec": "50000",
"Transient": "no",
"Type": "oneshot",
"UID": "4294967295",
"UMask": "0022",
"UnitFilePreset": "enabled",
"UnitFileState": "enabled",
"UtmpMode": "init",
"WantedBy": "multi-user.target",
"Wants": "[email protected]",
"WatchdogTimestampMonotonic": "0",
"WatchdogUSec": "0"
}
}
META: ran handlers