35 lines
914 B
YAML
35 lines
914 B
YAML
---
|
|
- name: setup target to be managed by ansible
|
|
hosts: all
|
|
tasks:
|
|
- name: warn people
|
|
lineinfile:
|
|
path: /etc/motd
|
|
create: yes
|
|
line: "Host is managed by ansible, manual interaction not recommended"
|
|
state: present
|
|
|
|
- name: history
|
|
lineinfile:
|
|
path: /etc/history
|
|
line: "{{ '%Y-%m-%d' | strftime }} - {{ ansible_play_name }}"
|
|
state: present
|
|
create: true
|
|
|
|
- name: create account
|
|
user:
|
|
name: ansible
|
|
password: "{{ '123Soleil%' | password_hash('sha512',65534|random(seed=inventory_hostname) | string) }}"
|
|
create_home: yes
|
|
home: /home/ansible
|
|
|
|
- name: configure sudo
|
|
copy:
|
|
content: "ansible ALL=(ALL) NOPASSWD: ALL"
|
|
dest: /etc/sudoers.d/ansible
|
|
validate: "/usr/sbin/visudo -cf %s"
|
|
|
|
- name: deploy ssh key
|
|
authorized_key:
|
|
user: ansible
|
|
key: "https://infra.opendoor.fr/id_rsa.pub" |