# Ansible

Ansible is a software that automates software provisioning, configuration management, and application deployment.

# Snippets

# Looping over a subelement

Variables:

users:
  - username: myles
    shell: /bin/bash
    authorized_keys:
      - "{{ lookup('file', 'ssh_keys/myles_laptop.pub') }}"
      - "{{ lookup('file', 'ssh_keys/myles_ipad.pub') }}"
      - "{{ lookup('file', 'ssh_keys/myles_iphone.pub') }}"
1
2
3
4
5
6
7

Tasks:

- name: add ~/.ssh/authorized_keys file for the user accounts
  authorized_key:
    user: '{{ item.0.username }}'
    key: "{{ item.1 }}"
  with_subelements:
    - '{{ users }}'
    - authorized_keys
  tags:
    - common
    - users
1
2
3
4
5
6
7
8
9
10
Last Updated: 12/26/2022, 5:42:03 PM