Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
183 views
in Technique[技术] by (71.8m points)

Ansible Tower problems copying .yml config file

Working in Ansible Tower, I am trying to update the codedeployagent.yml file on a server by copying a new version located in a github repo sub-folder called 'files'. However when I run the template in Ansible Tower, I get the following error (below):

ERROR! Syntax Error while loading YAML.
  mapping values are not allowed in this context
The error appears to be in '/tmp/awx/project/files/codedeployagent.yml': line 2, column 14, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
--
:log_aws_wire: false
             ^ here

It's like Ansible Tower is treating the codedeployagent.yml file as an ansible file when I don't want it to do that, I just want to copy the file. Could it be because the config file is a .yml format, do I need to change that in the source repo? This is my ansible playbook (below). Any suggestions appreciated, thanks.

---
-
  become: yes
  hosts: all
  remote_user: admin
  tasks:
    - block:
        - name: remove original CodeDeploy Agent config
          file:
            path: /etc/codedeploy-agent/conf/codedeployagent.yml
            state: absent

        - name: copy latest CodeDeploy Agent file
          template:
            dest: /etc/codedeploy-agent/conf/codedeployagent.yml
            mode: 420
            src: files/codedeployagent.yml
          tags:
            - config
        - name: restart CodeDeploy Agent
          service: name=codedeploy-agent state=restarted

  vars_files:
    - files/codedeployagent.yml
question from:https://stackoverflow.com/questions/65940424/ansible-tower-problems-copying-yml-config-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

just wanted to thank @Zeitounator for steering me in the right direction, the following ansible playbook now working nicely

---
-
  become: yes
  hosts: all
  remote_user: admin
  tasks:
    - block:
        - name: remove original CodeDeploy Agent config
          file:
            path: /etc/codedeploy-agent/conf/codedeployagent.yml
            state: absent

        - name: copy latest CodeDeploy Agent file
          template:
            dest: /etc/codedeploy-agent/conf/codedeployagent.yml
            mode: 420
            src: files/codedeployagent.yml
          tags:
            - config
        - name: restart CodeDeploy Agent
          service: name=codedeploy-agent state=restarted

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...