blob: 3fb1b18af4d36cc3f84314d95eeb9a37ec0c5e3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
---
- hosts: all
tasks:
- name: install lxc
package:
name: '{{item}}'
state: present
update_cache: yes
with_items:
- lxc
- python3-lxc
- name: Configuration de lxc
copy:
src: default.conf
dest: /etc/lxc/default.conf
- name: Creation d'un container rocky
community.general.lxc_container:
name: rocky-lxc
template: download
template_options: --dist rockylinux --release 9 --arch amd64
state: started
container_command: |
sleep 5
dnf install -y openssh-server python3
systemctl enable --now sshd
- name: Creation d'un container debian
community.general.lxc_container:
name: debian-lxc
template: download
template_options: --dist debian --release bookworm --arch amd64
state: started
container_command: |
sleep 5
apt install -y openssh-server python3
systemctl enable --now ssh
- name: copie des clefs ssh
copy:
src: "~/.ssh/id_rsa.pub"
dest: "{{item}}"
mode: "0600"
with_items:
- /var/lib/lxc/debian-lxc/rootfs/root/.ssh/authorized_keys
- /var/lib/lxc/rocky-lxc/rootfs/root/.ssh/authorized_keys
- name: recuperation ip rocky
shell: "lxc-info -iH rocky-lxc"
register: ip_rocky
- name: recuperation ip debian
shell: "lxc-info -iH debian-lxc"
register: ip_debian
- name: ssh-keyscan ip debian
remote_user: "jerome"
become: no
local_action: shell ssh-keyscan -H {{ip_debian.stdout}} >> ~/.ssh/known_hosts
- name: ssh-keyscan ip rocky
remote_user: "jerome"
become: no
local_action: shell ssh-keyscan -H {{ip_rocky.stdout}} >> ~/.ssh/known_hosts
- name: inventaire
remote_user: "jerome"
become: no
local_action: copy content="[containers]\n{{ip_rocky.stdout}}\n{{ip_debian.stdout}}" dest="hosts"
|