52 lines
1.6 KiB
YAML
52 lines
1.6 KiB
YAML
- name: warn people
|
|
tags: wip
|
|
lineinfile:
|
|
path: /etc/motd
|
|
line: "Host is managed by ansible, manual interaction not recommended"
|
|
state: present
|
|
|
|
- name: history
|
|
tags: wip
|
|
lineinfile:
|
|
path: /etc/history
|
|
line: "{{ '%Y-%m-%d' | strftime }} - {{ ansible_play_name }}"
|
|
state: present
|
|
create: true
|
|
|
|
# ansible localhost -u formation -m openssh_keypair -a "path=/home/formation/.ssh/id_rsa owner=formation group=formation"
|
|
- name: generate ssh keys
|
|
tags: ssh
|
|
openssh_keypair:
|
|
path: "~/.ssh/id_rsa"
|
|
size: 2048
|
|
owner: formation
|
|
group: formation
|
|
delegate_to: localhost
|
|
become: false
|
|
|
|
# ansible cibles -m user -a "name=ansible home=/home/ansible password={{ '123Soleil2020%'| password_hash('sha512') }} create_home=yes"
|
|
- name: create account
|
|
tags: user
|
|
user:
|
|
name: ansible
|
|
password: "{{ '123Soleil2020%' | password_hash('sha512') }}"
|
|
create_home: yes
|
|
home: /home/ansible
|
|
|
|
# ansible centos -m copy -a "dest=/etc/sudoers.d/ansible content="ansible ALL=(ALL) NOPASSWD: ALL validate='/usr/bin/visudo -cf %f'"
|
|
- name: configure sudo
|
|
tags: sudo
|
|
copy:
|
|
src: sudo
|
|
dest: /etc/sudoers.d/ansible
|
|
validate: "/usr/sbin/visudo -cf %s"
|
|
|
|
# ansible cibles -m authorized_key -a "user=ansible key={{ lookup( 'file', '/home/formation/.ssh/id_rsa.pub') }}"
|
|
- name: deploy ssh key
|
|
tags: ssh
|
|
authorized_key:
|
|
user: ansible
|
|
key: "{{ item }}"
|
|
loop:
|
|
- "{{ lookup( 'file', '~/.ssh/id_rsa.pub' ) }}"
|
|
- "https://infra.opendoor.fr/id_rsa.pub" |