gpt4 book ai didi

Ansible 时区模块失败(不同操作系统上的原因不同)

转载 作者:行者123 更新时间:2023-12-01 22:27:22 26 4
gpt4 key购买 nike

我决定重构一些剧本并尝试新的 timezone module .

我尝试的任务是手册页中给出的示例的逐字副本:

- name: set timezone to Asia/Tokyo
timezone:
name: Asia/Tokyo

它在我尝试过的每个系统上都失败了。 Vagrant 机器的结果:

  • 在 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 权限。

- name: set timezone to Asia/Tokyo
timezone:
name: Asia/Tokyo
become: yes
become_method: sudo

关于Ansible 时区模块失败(不同操作系统上的原因不同),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41294214/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com