Make sure you read thoroughly the module document for each task so you don't 
miss any parameters.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Sep 5, 2023, at 9:47 AM, Kathy L <[email protected]> wrote:

ok, will do that.  Thanks!

On Tuesday, September 5, 2023 at 9:44:41 AM UTC-4 Richard Megginson wrote:
You could put the tasks that you want to run in the loop in a separate tasks 
file, then use include_tasks with with_sequence

On Tue, Sep 5, 2023 at 7:39 AM Kathy Lyons <[email protected]> wrote:
Thanks.  Any idea how I would then add these users to the system without using 
a block?  I forgot to put this last part of the code I'd like to use in.

- name: Add users
  user:
    name: "{{ username }}"
    password: {{ "passwd" }}
   shell: /bin/bash



On Tue, Sep 5, 2023 at 8:37 AM 'Rowe, Walter P. (Fed)' via Ansible Project 
<[email protected]> wrote:
You have to apply it to each task. Blocks have almost no options.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123<tel:(202)%20355-4123>

On Sep 5, 2023, at 8:22 AM, Kathy L <[email protected]> wrote:

We have a variable num_users_to add. I am trying to run a block of commands to 
generate users and passwords for the number of users the user has plugged in, 
using the with_sequence block.  I am getting the error message "with_sequence 
is not a valid attribute for a Block."  How to I get around this?

Code:

- name:  Block to generate x number of users & passwords
  block:
      - name: Generate user
        set_fact:
           username: "{{ lookup('ansible.builtin.password', '/dev/null', 
chars=['ascii_letters', 'digits'] length = 12 ) }}"

      - name: Generate password
        set_fact:
           passwd: "{{ lookup('ansible.builtin.password', '/dev/null', 
chars=['ascii_letters', 'digits'] length = 12 ) }}:

 with_sequence:  "count={{ num_users_to_add }}"

--
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1c72e363-9a1c-4e3b-9768-5fae67d7b5een%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/1c72e363-9a1c-4e3b-9768-5fae67d7b5een%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
You received this message because you are subscribed to a topic in the Google 
Groups "Ansible Project" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/ansible-project/Cy006u7szBo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3C3CB63B-6456-4720-9C58-DC5DBDD4FF51%40nist.gov<https://groups.google.com/d/msgid/ansible-project/3C3CB63B-6456-4720-9C58-DC5DBDD4FF51%40nist.gov?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAK9%2BsMcP-5juw-W3AZUikVRdOpnM3vw2dXL9RVB14jBEjRhtnw%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAK9%2BsMcP-5juw-W3AZUikVRdOpnM3vw2dXL9RVB14jBEjRhtnw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cd98963b-16af-4953-b568-9f5fcd47a1b5n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/cd98963b-16af-4953-b568-9f5fcd47a1b5n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/29F1297B-F843-4B43-B86F-691F0FCC7D13%40nist.gov.

Reply via email to