47 lines
1.7 KiB
Markdown
47 lines
1.7 KiB
Markdown
## Atelier d'introduction
|
|
|
|
ansible cibles -m command -a uptime -o
|
|
|
|
ansible cibles -m copy -a 'src=/etc/profile.d/z_my_profile.sh dest=/etc/profile.d mode=0644 owner=root group=root'
|
|
|
|
ansible centos -m yum -a 'name=vim-enhanced state=present'
|
|
|
|
ansible centos -m yum -a 'name=nano state=absent'
|
|
|
|
|
|
ansible cibles -m file -a 'path=/srv/sib owner=formation state=directory'
|
|
|
|
|
|
ansible cibles -m lineinfile -a 'path=/etc/profile.d/editor.sh create=true line="export EDITOR=vim" state=present'
|
|
|
|
ansible cibles -m get_url -a 'url=https://cours.opendoor.fr/Fichiers/vimrc dest=/etc/vimrc mode=0644'
|
|
|
|
|
|
ansible centos -m service -a 'name=crond state=restarted'
|
|
|
|
|
|
## Setup
|
|
|
|
ansible localhost -m community.crypto.openssh_keypair -a 'path=/home/formation/.ssh/id_rsa owner=formation group=formation' -u formation
|
|
|
|
#l'inversion des quotes permet l'utilisation du ! dans le mot de passe
|
|
|
|
```bash
|
|
ansible cibles -m ansible.builtin.user -a 'user=ansible password={{ "123Soleil!"| password_hash( "sha512", 65534 | random(seed=inventory_hostname) | string) }} create_home=yes home=/home/ansible'
|
|
```
|
|
|
|
```bash
|
|
ansible cibles -m ansible.builtin.lineinfile -a 'path=/etc/sudoers.d/ansible state=present create=yes line="ansible ALL=(ALL) NOPASSWD: ALL" validate="/usr/sbin/visudo -cf %s"'
|
|
```
|
|
|
|
```bash
|
|
ansible cibles -m ansible.builtin.copy -a 'dest=/etc/sudoers.d/ansible content="ansible ALL=(ALL) NOPASSWD: ALL" validate="/usr/sbin/visudo -cf %s"'
|
|
```
|
|
```bash
|
|
ansible cibles -o -m community.general.sudoers -a 'name="ansible" user=ansible commands=ALL nopassword=true'
|
|
```
|
|
|
|
```bash
|
|
ansible cibles -u formation -k -m ansible.posix.authorized_key -a 'key={{ lookup( "file", "~/.ssh/id_rsa.pub") }} user=ansible'
|
|
```
|