UA-Cores
UA-Cores

Reputation: 11

Ansible playbook: unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>

I've tried about 1000 permutations of moving stuff around, changing indentation, tasks, putting hosts under each name section, etc. All I can do is move the errors around. YAML is valid FWIW.

"This post is mostly code, so I've added some more verbiage to please the stack exchange parser"--> Because the problem is probably obvious to anyone who knows yaml. I bet you could fix it with the error and the code and nothing else. But I'll write a few more irrelevant sentences. etc. etc.

---
- hosts: all
  ignore_errors: yes
  tasks:
  
  - name: Copy config files
    become: true
    copy:
      src: root/
      dest: /
      force: 'yes'

  - name: Create arladmin user
    become: true
    vars:
      groups_to_create:
        - name: arladmin
      users:
        - name: RIIAdminAcct
          username: arladmin
          password: $1$9gc3Af.S$nhCm9chfOMSIYgZgJNs9G1
          groups:
            - users
            - bin
            - root
            - sudo
          shell: /bin/bash
          profile: |
            alias ll='ls -lah'
            alias cp='cp -iv'
          ssh_key:
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAIGDIsgiCLj0y3iRFkNYi5ddBPtLiG6teZFTwwgj6b5n3
              summer@summerriilaptop
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAIBykJ1eYprvJaU9oN1qUI1lkYxzGYOYNyUXtwf3FOS/+
              summer@home
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAINNWYzSVVT+sbOr9Zh0chIAMcWm9lMrH+2QgpqQycmEg
              summer@homeworklaptop
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAIC5A8Ma62u9ppKjU0rlF3zMPSafnIAS1zWL3JJYqFSAS
              root@homeworklaptop
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAIILXD3jn8XOTkcEgqmL9E6pkK3hu7joq7iwPxw97GeV7
              summer@trabajo
    roles:
      - ansible-users

  - name: Install Packages
    become: true
    apt:
      state: latest
      update_cache: 'yes'
      pkg:
        - git
        - procps
        - nginx
        - python3
        - python3-django-uwsgi
        - node-js-beautify
        - xfce4
        - slim
        - cockpit
        - tigervnc-standalone-server
        - tigervnc-common
        - tigervnc-xorg-extension
        - tigervnc-viewer
  
  - name: Start nginx
    service:
      name: nginx
      state: started
      enabled: 'yes'

Upvotes: 1

Views: 2179

Answers (1)

gary lopez
gary lopez

Reputation: 1954

You could try two ways.

  1. Change the task Create arladmin user using include_role module. This module doesn't accept become attribute, then you could add the task to a block and use become in the block not in the task as below
- block:
  - name: Create arladmin user
    vars:
      groups_to_create:
        - name: arladmin
      users:
        - name: RIIAdminAcct
          username: arladmin
          password: $1$9gc3Af.S$nhCm9chfOMSIYgZgJNs9G1
          groups:
            - users
            - bin
            - root
            - sudo
          shell: /bin/bash
          profile: |
            alias ll='ls -lah'
            alias cp='cp -iv'
          ssh_key:
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAIGDIsgiCLj0y3iRFkNYi5ddBPtLiG6teZFTwwgj6b5n3
              summer@summerriilaptop
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAIBykJ1eYprvJaU9oN1qUI1lkYxzGYOYNyUXtwf3FOS/+
              summer@home
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAINNWYzSVVT+sbOr9Zh0chIAMcWm9lMrH+2QgpqQycmEg
              summer@homeworklaptop
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAIC5A8Ma62u9ppKjU0rlF3zMPSafnIAS1zWL3JJYqFSAS
              root@homeworklaptop
            - >-
              ssh-ed25519
              AAAAC3NzaC1lZDI1NTE5AAAAIILXD3jn8XOTkcEgqmL9E6pkK3hu7joq7iwPxw97GeV7
              summer@trabajo
    include_role:
      name: ansible-users
  become: yes
  1. Modify all playbook as below:
---
- hosts: all
  ignore_errors: yes
  vars:
    groups_to_create:
      - name: arladmin
    users:
      - name: RIIAdminAcct
        username: arladmin
        password: $1$9gc3Af.S$nhCm9chfOMSIYgZgJNs9G1
        groups:
          - users
          - bin
          - root
          - sudo
        shell: /bin/bash
        profile: |
          alias ll='ls -lah'
          alias cp='cp -iv'
        ssh_key:
          - >-
            ssh-ed25519
            AAAAC3NzaC1lZDI1NTE5AAAAIGDIsgiCLj0y3iRFkNYi5ddBPtLiG6teZFTwwgj6b5n3
            summer@summerriilaptop
          - >-
            ssh-ed25519
            AAAAC3NzaC1lZDI1NTE5AAAAIBykJ1eYprvJaU9oN1qUI1lkYxzGYOYNyUXtwf3FOS/+
            summer@home
          - >-
            ssh-ed25519
            AAAAC3NzaC1lZDI1NTE5AAAAINNWYzSVVT+sbOr9Zh0chIAMcWm9lMrH+2QgpqQycmEg
            summer@homeworklaptop
          - >-
            ssh-ed25519
            AAAAC3NzaC1lZDI1NTE5AAAAIC5A8Ma62u9ppKjU0rlF3zMPSafnIAS1zWL3JJYqFSAS
            root@homeworklaptop
          - >-
            ssh-ed25519
            AAAAC3NzaC1lZDI1NTE5AAAAIILXD3jn8XOTkcEgqmL9E6pkK3hu7joq7iwPxw97GeV7
            summer@trabajo

  roles:
    - ansible-users

  tasks:
  - name: Copy config files
    become: true
    copy:
      src: root/
      dest: /
      force: 'yes'

  - name: Create arladmin user
    become: true

  - name: Install Packages
    become: true
    apt:
      state: latest
      update_cache: 'yes'
      pkg:
        - git
        - procps
        - nginx
        - python3
        - python3-django-uwsgi
        - node-js-beautify
        - xfce4
        - slim
        - cockpit
        - tigervnc-standalone-server
        - tigervnc-common
        - tigervnc-xorg-extension
        - tigervnc-viewer
  
  - name: Start nginx
    service:
      name: nginx
      state: started
      enabled: 'yes'

Upvotes: 1

Related Questions