Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| debadc2d8f | |||
| e9eb38a6c6 | |||
| 2cb4827bc4 | |||
| 17c6f5bba2 |
@@ -16,9 +16,8 @@ Le fichier peut être ouvert avec l'application keepassx avec le mot de passe su
|
|||||||
Voir aussi: https://github.com/viczem/ansible-keepass
|
Voir aussi: https://github.com/viczem/ansible-keepass
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip3 install 'pykeepass==3.2.1' --user
|
pip3 install 'pykeepass==4.0.3' --user
|
||||||
mkdir -p ~/.ansible/plugins/lookup && cd "$_"
|
ansible-galaxy collection install viczem.keepass
|
||||||
curl https://raw.githubusercontent.com/viczem/ansible-keepass/master/keepass.py -o ./keepass.py
|
|
||||||
```
|
```
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
@@ -36,7 +35,7 @@ keepass_psw: 123Soleil
|
|||||||
|
|
||||||
Il suffit d'utiliser l'instruction
|
Il suffit d'utiliser l'instruction
|
||||||
```yaml
|
```yaml
|
||||||
lookup( 'keepass', 'Groupe/entrée", 'type')
|
lookup( 'viczem.keepass.keepass', 'Groupe/entrée", 'type')
|
||||||
```
|
```
|
||||||
|
|
||||||
Groupe: nom du groupe, en ignorant le groupe de premier niveau. Donc vide dans notre exemple
|
Groupe: nom du groupe, en ignorant le groupe de premier niveau. Donc vide dans notre exemple
|
||||||
|
|||||||
50
setup.yml
Normal file
50
setup.yml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
---
|
||||||
|
- name: setup target to be managed by ansible
|
||||||
|
hosts: cibles
|
||||||
|
vars:
|
||||||
|
password: "{{lookup( 'viczem.keepass.keepass', 'ansible shell', 'password') }}"
|
||||||
|
username: "{{ lookup( 'viczem.keepass.keepass', 'ansible shell', 'username') }}"
|
||||||
|
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: generate ssh keys
|
||||||
|
openssh_keypair:
|
||||||
|
path: "~/.ssh/id_rsa"
|
||||||
|
size: 2048
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
|
||||||
|
- name: create account
|
||||||
|
tags: lookup
|
||||||
|
vars:
|
||||||
|
user:
|
||||||
|
name: "{{ username }}"
|
||||||
|
password: "{{ password | password_hash('sha512',65534|random(seed=inventory_hostname) | string) }}"
|
||||||
|
create_home: yes
|
||||||
|
home: "/home/{{ username }}"
|
||||||
|
|
||||||
|
- name: configure sudo
|
||||||
|
copy:
|
||||||
|
content: "{{ username }} ALL=(ALL) NOPASSWD: ALL"
|
||||||
|
dest: /etc/sudoers.d/ansible
|
||||||
|
validate: "/usr/sbin/visudo -cf %s"
|
||||||
|
|
||||||
|
- name: deploy ssh key
|
||||||
|
authorized_key:
|
||||||
|
user: "{{ username }}"
|
||||||
|
key: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- "{{ lookup( 'file', '~/.ssh/id_rsa.pub' ) }}"
|
||||||
|
- "https://infra.opendoor.fr/id_rsa.pub"
|
||||||
Reference in New Issue
Block a user