首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用AWX而不是命令行发出

使用AWX而不是命令行发出
EN

Stack Overflow用户
提问于 2022-10-31 10:38:57
回答 1查看 21关注 0票数 1

我在ansible中有一个角色,在命令行工作,但不是通过awx。

在这方面,作用:

代码语言:javascript
复制
- name: Enable persistent logging
  ansible.builtin.lineinfile:
    path: /etc/systemd/journald.conf
    regexp: '^#Storage'
    line: Storage=persistent

- name: Check directory
  ansible.builtin.stat:
    path: "{{ journal_dir }}"
  register: journaldir

- block:
  - name: Create directory
    ansible.builtin.file:
      path: "{{ journal_dir }}"
      state: directory
      mode: '0755'

  - name: Enable systemd-tmpfiles folder
    ansible.builtin.command: /bin/systemd-tmpfiles --create --prefix {{ journal_dir }}
    check_mode: no
    notify:
      - restart systemd-journald

  when: journaldir.stat.exists == false and ansible_distribution_major_version >= '7'

在这里,通知代码:

代码语言:javascript
复制
- name: restart systemd-journald
  ansible.builtin.service:
    name: systemd-journald
    state: restarted

{ journal_dir } is /var/log/日志

当我在我的终端上运行剧本时,我没有问题,但是当我使用awx运行它时,我仍然有以下错误:

代码语言:javascript
复制
TASK [journalctl : Enable systemd-tmpfiles folder] *****************************
fatal: [server]: FAILED! => {"changed": false, "msg": "no command given", "rc": 256}

我也用shell模块做过测试,这是相同的行为。

我不明白为什么。

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-31 16:33:07

对于这个问题,我似乎使用了ansible的旧版本,所以我不得不删除命令模块的fqcn。

它的工作方式如下:

代码语言:javascript
复制
  - name: Enable systemd-tmpfiles folder
    command: /bin/systemd-tmpfiles --create --prefix {{ journal_dir }}
    notify: 
      - restart systemd-journald

我通过命令行的不可用版本是2.9.27,awx的ansible版本是2.9.14。

在这里找到了解决方案:Ansible cant run any command or shell

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74262027

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档