cancel
Showing results for 
Search instead for 
Did you mean: 
hvonderheyde
Mission Specialist
Mission Specialist
  • 372 Views

DO374 chapter 7 guided exercise data loops s06

Hello folks,

within the 3rd task of this guided exercise the public key of 4 users will be deployed with the following playbook:

- name: Third task
  hosts: servera.lab.example.com
  gather_facts: false
  become: true

  tasks:
    - name: Set up authorized keys
      ansible.posix.authorized_key:
        user: developer
        state: present
        key: "{{ lookup('ansible.builtin.file', item) }}" loop: "{{ public_key_lists | map(attribute='public_keys') | flatten }}"

This works like a charm.

But when adding a ssh key, you should also be able to remove it.

But when I try to remove a key from one of the users e.g. lisa ( adding exclusive: true to the module), the playbook isn't working. All the 4 keys will be removed in this case. Does anyone knows how to modify the playbook to be able to remove a key ? 

Thanks a lot in advance.

regards Hendrik

 

Labels (1)
0 Kudos
1 Reply
carlos_arias
Moderator
Moderator
  • 332 Views

Hi Hendrik, 

Now I can only think of an alternative such creating another group_vars file to remove a particular key, with the same structure as the ~/data-loops/group_vars/all/my_vars.yml file, but only including the names of the users to remove the key.

RHCA - Level III
Free software for free people
0 Kudos
Join the discussion
You must log in to join this conversation.