S
S
sflyer2018-02-08 06:43:56
YAML
sflyer, 2018-02-08 06:43:56

Ansible + awx. What is the problem in yaml file?

I'm learning ansible, I'm trying to run at least one yaml for verification. Using Google, I wrote what is below to update the system via apt. But it doesn't work, I can't figure out what's wrong. Prompt the beginner - where to dig? Thanks in advance

---
- hosts: all
  sudo: yes
  tasks: 
- name: Update and upgrade apt packages
  become: true
  apt:
    upgrade: yes
    update_cache: yes
cache_valid_time: 86400

Mistake:
ERROR! 'apt' is not a valid attribute for a Play
The error appears to have been in '/var/lib/awx/projects/_8__test/test.yaml': line 5, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: Update and upgrade apt packages
^ here

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Varyukhin, 2018-02-08
@sflyer

Obviously the problem is indentation.

- hosts: all
  sudo: yes
  tasks: 
    - name: Update and upgrade apt packages
      become: true
      apt: upgrade=yes update_cache=yes cache_valid_time=86400

Maybe something like this?

P
Puma Thailand, 2018-02-08
@opium

this is a python, the whole syntax is tied to indents, and they dance like a Christmas tree and you will understand what you wrote

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question