summaryrefslogtreecommitdiff
path: root/playbooks/lxc.yml
diff options
context:
space:
mode:
authorjerome <jerome@xlinfo.fr>2025-02-07 11:40:40 +0100
committerjerome <jerome@xlinfo.fr>2025-02-07 11:40:40 +0100
commit69b3a2cf08873de59883e3c2661ea1b57726eee3 (patch)
tree79824f61bf1a6b556d85fd652f3b6ead787a4744 /playbooks/lxc.yml
downloadterraform-ansible-69b3a2cf08873de59883e3c2661ea1b57726eee3.tar.gz
terraform-ansible-69b3a2cf08873de59883e3c2661ea1b57726eee3.zip
premier commit
Diffstat (limited to 'playbooks/lxc.yml')
-rw-r--r--playbooks/lxc.yml62
1 files changed, 62 insertions, 0 deletions
diff --git a/playbooks/lxc.yml b/playbooks/lxc.yml
new file mode 100644
index 0000000..8c40007
--- /dev/null
+++ b/playbooks/lxc.yml
@@ -0,0 +1,62 @@
+---
+- 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: inventaire
+ remote_user: "jerome"
+ become: no
+ local_action: copy content="{{ip_rocky.stdout}}\n{{ip_debian.stdout}}" dest="hosts"
+