我決定重構一些劇本並嘗試新的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