
---
- hosts: test_server
remote_user: root
tasks:
- name: extract tar file
command: tar -xvzf httpd-2.4.41.tar.gz
- name: go to the extracted directory
command: cd httpd-2.4.41
- name: Run below commands
command:
- ./configure --prefix=instance --with-mpm=worker --enable-proxy -enable-deflate --enable-proxy-balancer --enable-rewrite --enable-apr -enable-apr-util --enable-ssl --enable-setenvif --with-ssl=/usr/local/ssl
- make
- make install
- name: change directory
command: cd
- name: check version
command: /app/apache/instance/bin/apachectl -v
- name: start httpd
command: /app/apache/instance/bin/apachectl start
しかし、次のエラーが発生しました。
[root@91c2ebbd3d57 ~]# ansible-playbook test.yml
ERROR! Syntax Error while loading YAML.
did not find expected '-' indicator
エラーは "/root/test.yml": 14行目、6列目にあるようですが、正確な構文の問題によっては、ファイルの他の場所にある可能性があります。
問題のある行は次のとおりです。
- make install
- name: change directory
^ here
答え1
この試み
---
- hosts: test_server
remote_user: root
tasks:
- name: extract tar file
command: tar -xvzf httpd-2.4.41.tar.gz
- name: Run below commands
shell: |
./configure \
--prefix=instance \
--with-mpm=worker \
--enable-proxy \
--enable-deflate \
--enable-proxy-balancer \
--enable-rewrite \
--enable-apr \
--enable-apr-util \
--enable-ssl \
--enable-setenvif \
--with-ssl=/usr/local/ssl
make
make install
args:
chdir: /root/httpd-2.4.41
- name: check version
command: /app/apache/instance/bin/apachectl -v
- name: start httpd
command: /app/apache/instance/bin/apachectl start`
答え2
問題(構文エラー)は、- name: change directory
この行とそれに続くすべての行をインデントすることです。すべて1つずつあまりにもインデントされています。