我决定重构一些剧本并尝试新的timezone
module。Ansible时区模块失败(不同操作系统上的不同原因)
我尝试的任务是在手册中给出的例子的完整副本:
- name: set timezone to Asia/Tokyo
timezone:
name: Asia/Tokyo
它未能每个系统我试了。结果流浪机器:
在Debian 8(
debian/jessie64
):TASK [set timezone to Asia/Tokyo] **********************************************
fatal: [debian]: FAILED! => {"changed": false, "cmd": "/usr/bin/timedatectl set-timezone Asia/Tokyo", "failed": true, "msg": "Failed to set time zone: The name org.freedesktop.PolicyKit1 was not provided by any .service files", "rc": 1, "stderr": "Failed to set time zone: The name org.freedesktop.PolicyKit1 was not provided by any .service files\n", "stdout": "", "stdout_lines": []}在CentOS 7(
centos/7
) - 不同的Debian:TASK [set timezone to Asia/Tokyo] **********************************************
fatal: [centos]: FAILED! => {"changed": false, "cmd": "/usr/bin/timedatectl set-timezone Asia/Tokyo", "failed": true, "msg": "Failed to set time zone: Interactive authentication required.", "rc": 1, "stderr": "Failed to set time zone: Interactive authentication required.\n", "stdout": "", "stdout_lines": []}在Ubuntu 16.04(
ubuntu/xenial64
) - 与CentOS相同,与Debian不同:TASK [set timezone to Asia/Tokyo] **********************************************
fatal: [ubuntu]: FAILED! => {"changed": false, "cmd": "/usr/bin/timedatectl set-timezone Asia/Tokyo", "failed": true, "msg": "Failed to set time zone: Interactive authentication required.", "rc": 1, "stderr": "Failed to set time zone: Interactive authentication required.\n", "stdout": "", "stdout_lines": []}
我错过了什么吗?是否需要某些依赖项?
'timedatectl'需要'sudo'特权。你可以尝试'时区'与'成为:是'和'成为方法:sudo'? – helloV
就是这样!我被Debian的信息所忽略,然后是操作系统之间的差异,而不是解释消息所说的内容。谢谢。 – techraf