Unexpected parameter type in new Ansible role

3,336 views
Skip to first unread message

harry devine

unread,
Mar 9, 2020, 1:48:26 PM3/9/20
to Ansible Project
I'm trying to create a role that will update Satellite content views using the Foreman/Katello modules.  Here's what the role tree looks like:

 [root@server1 /etc/ansible/roles/foreman_content_views]#tree
.
├── defaults
│   └── main.yml
├── tasks
│   ├── clean_cv.yml
│   └── main.yml
└── vars
    └── main.yml

3 directories, 4 files

If I check the syntax on each YML file using "ansible-playbook --syntax-check" they check out fine.  But when I run the main playbook, I get the following error after I include the role:

PLAY [Manage Satellite Content Views] **************************************************************************************************************************************************

TASK [Manage Satellite Content Views] **************************************************************************************************************************************************
ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>

The error appears to be in '/etc/ansible/roles/foreman_content_views/tasks/main.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Playbook to perform a repo sync from the sat server
  ^ here

Here's the main playbook I'm running to start the run:
---
- name: "Manage Satellite Content Views"
  hosts: server1
  gather_facts: no

  tasks:
    - name: "Manage Satellite Content Views"
      include_role:
        name: "foreman_content_views"

The main.yml under tasks is as follows:

- name: Playbook to perform a repo sync from the sat server
  hosts: localhost

  tasks:
  # Sync all repositories
  - name: Get all repositories
    foreman_search_facts:
      username: "{{sat_user}}"
      password: "{{sat_passwd}}"
      server_url: "https://{{sat_server_fqdn}}"
      resource: repositories
      validate_certs: "{{validate_sat_cert}}"
    register: repositories


Any ideas on what could be going on?

Thanks,
Harry

Dick Visser

unread,
Mar 9, 2020, 3:23:46 PM3/9/20
to ansible...@googlegroups.com
Hi


On Mon, 9 Mar 2020 at 18:48, harry devine <lift...@gmail.com> wrote:

> The main.yml under tasks is as follows:
>
> - name: Playbook to perform a repo sync from the sat server
> hosts: localhost
>
> tasks:
> # Sync all repositories
> - name: Get all repositories
> foreman_search_facts:
> username: "{{sat_user}}"
> password: "{{sat_passwd}}"
> server_url: "https://{{sat_server_fqdn}}"
> resource: repositories
> validate_certs: "{{validate_sat_cert}}"
> register: repositories
>
>
> Any ideas on what could be going on?

Yes, your main.yml should ONLY contain a list of tasks - you also have
hosts, and an actual tasks entry.
You can just strip the first lines and intend the rest, so your
main.yml look like this:

---
- name: Get all repositories
foreman_search_facts:
username: "{{sat_user}}"
password: "{{sat_passwd}}"
server_url: "https://{{sat_server_fqdn}}"
resource: repositories
validate_certs: "{{validate_sat_cert}}"
register: repositories





--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
Reply all
Reply to author
Forward
0 new messages