Files
Terraform/.ansible.d/setup.yml
2024-12-09 23:10:42 -06:00

46 lines
1.1 KiB
YAML

---
- name: Setup Ansible User and Environment
hosts: all
remote_user: root
become: yes
tasks:
- name: Install Standard Packages
apt:
name:
- python3-full
- python3-pip
- sudo
- vim
- net-tools
state: present
update_cache: yes
- name: Create ansible user
user:
name: ansible
state: present
create_home: yes
shell: /bin/bash
groups: ["users", "sudo"]
password: "$6$F.AQzOBfVmeadQ3N$QYqzkqZ0qQiet0TlfYsWQelTJaBIiWjSVGuahrhCN5Ir7qX6goUjariH0YiD0muqd9c9r9xUWbZm3xExfK3Ri1"
- name: Set ansible password
command: echo "ansible:$(cat ./ansible.pass)" | chpasswd
become: yes
- name: Create .ssh directory
file:
path: "/home/ansible/.ssh"
state: directory
owner: ansible
group: ansible
mode: '0700'
- name: Set Ansible authorized_keys
ansible.posix.authorized_key:
user: "ansible"
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIjMDDhinpnCPFUMERa/tLYymzRI8oJoAvXZnBH9wpA4 fake@gmail.com"
state: present