gpt4 book ai didi

python - Ansible:tasks/main.yml 文件中的操作语句存在冲突

转载 作者:行者123 更新时间:2023-11-30 23:00:56 26 4
gpt4 key购买 nike

这是我的目录结构:

/roles
/apache
/files
/handlers
/meta
/tasks
/templates
/vars
ansible.cfg
hosts
playbook.yml

这是我的tasks/main.yml 文件内容:

---
- name: Add Apache2 repository
apt_repository: repo='ppa:ondrej/apache2' state=present
register: apacherepositoryinstalled

- name: Install Apache2
apt: pkg=apache2 state=latest update_cache=true
when: apacherepositoryinstalled|success
register: apacheinstalled
service: name=apache2 state=started

- name: Enable rewrite module
apache2_module: state=present name=rewrite
when: apacheinstalled|success
register: rewritemoduleenabled

- name: Add production virtual host configuration
template: src=production.conf.j2 dest=/etc/apache2/sites-available/production.conf owner=root group=root

- name: Enable production virtual host configuration
file: src=/etc/apache2/sites-available/production.conf dest=/etc/apache2/sites-enabled/production.conf

- name: Add staging virtual host configuration
file: src=staging.conf.j2 dest=/etc/apache2/sites-available/staging.conf owner=root group=root

- name: Enable staging virtual host configuration
file: src=/etc/apache2/sites-available/staging.conf dest=/etc/apache2/sites-enabled/staging.conf

- name: Reload Apache2 Service
service: name=apache2 state=reloaded

以下是 Ansible 脚本抛出的错误消息:

The error appears to have been in '/home/vagrant/ansible/roles/apache/tasks/main.yml': line 6, column 4, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Install Apache2
^ here

我是否遗漏了一些明显的东西?

提前致谢。

最佳答案

您指定了多个操作。 service 必须执行单独的操作。将其更改为:

- name: Install Apache2
apt: pkg=apache2 state=latest update_cache=true
when: apacherepositoryinstalled|success
register: apacheinstalled
- service: name=apache2 state=started

关于python - Ansible:tasks/main.yml 文件中的操作语句存在冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35067526/

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