deployAnsible.yml 936 Bytes
---
- hosts: new-host
  become: true
  tasks:
    - name: New Ansbile Group
      group:
          name: ansbile
          state: present
          
    - name: New Ansible User
      user:
          uid: 1111
          home: /home/ansible
          name: ansible
          group: ansible
          shell: /bin/bash
          system: no
          createhome: yes
      
    - name: Grant Permission
      command: usermod -aG sudo ansible
    
    - name: New Directory for authorized_keys
         file:
             path: "{{ item.path }}"
             owner: "{{ item.owner }}"
             group: "{{ item.owner }}"
             state: directory
         with_items:
             - { owner: ansible, path: /home/ansible/.ssh }

    - copy:
            src: /tmp/configuration/authorized_keys
            dest: /home/ansible/.ssh/authorized_keys
            owner: ansible
            group: ansible
            mode: 0600
# Update 2