Sfoglia il codice sorgente

update inventory, change become method, etc.

Benoît Hubert 1 anno fa
parent
commit
43e2631c92

+ 133 - 0
ansible-initial-debian-setup/README.md

@@ -126,3 +126,136 @@ ansible-playbook -i inventory.ini playbook-add-debian-sudoers.yml --ask-vault-pa
 > **→ c'est pas tellement simple**... mais en même temps sans `sudo` on fait ce qu'on peut.
 
 Peut-être qu'un `-K` pour juste demander le mot de passe root sans le mettre dans un vault...
+
+## Lundi 19/02 aprem
+
+### prep
+
+- divise inventory en 2 parties (debian et alpine)
+
+### alpine
+
+#### 1er essai
+
+```
+$ ansible -i ./inventory.ini alpine -m ping -u alpine -k
+SSH password: 
+[WARNING]: No python interpreters found for host 192.168.1.48 (tried ['python3.11', 'python3.10', 'python3.9', 'python3.8', 'python3.7',
+'python3.6', 'python3.5', '/usr/bin/python3', '/usr/libexec/platform-python', 'python2.7', '/usr/bin/python', 'python'])
+192.168.1.48 | FAILED! => {
+    "ansible_facts": {
+        "discovered_interpreter_python": "/usr/bin/python"
+    },
+    "changed": false,
+    "module_stderr": "Shared connection to 192.168.1.48 closed.\r\n",
+    "module_stdout": "/bin/sh: /usr/bin/python: not found\r\n",
+    "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error",
+    "rc": 127
+}
+[WARNING]: No python interpreters found for host 192.168.1.72 (tried ['python3.11', 'python3.10', 'python3.9', 'python3.8', 'python3.7',
+'python3.6', 'python3.5', '/usr/bin/python3', '/usr/libexec/platform-python', 'python2.7', '/usr/bin/python', 'python'])
+192.168.1.72 | FAILED! => {
+    "ansible_facts": {
+        "discovered_interpreter_python": "/usr/bin/python"
+    },
+    "changed": false,
+    "module_stderr": "Shared connection to 192.168.1.72 closed.\r\n",
+    "module_stdout": "/bin/sh: /usr/bin/python: not found\r\n",
+    "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error",
+    "rc": 127
+}
+```
+
+#### faire installer python3
+
+Attention
+
+- cibler hosts `alpine`
+
+```yaml
+- hosts: alpine
+  gather_facts: no
+  tasks:
+    - name: Install Python3
+      raw: apk update && apk add python3
+```
+
+exec va demander
+
+- password ssh
+- password become
+
+```
+ansible-playbook -i inventory.ini playbook-install-python-alpine.yml -u alpine -bkK
+```
+
+#### 2nde tentative ping
+
+```
+$ ansible -i ./inventory.ini alpine -m ping -u alpine -k
+SSH password: 
+[WARNING]: Platform linux on host 192.168.1.72 is using the discovered Python interpreter at /usr/bin/python3.11, but future installation
+of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-
+core/2.15/reference_appendices/interpreter_discovery.html for more information.
+192.168.1.72 | SUCCESS => {
+    "ansible_facts": {
+        "discovered_interpreter_python": "/usr/bin/python3.11"
+    },
+    "changed": false,
+    "ping": "pong"
+}
+[WARNING]: Platform linux on host 192.168.1.48 is using the discovered Python interpreter at /usr/bin/python3.11, but future installation
+of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-
+core/2.15/reference_appendices/interpreter_discovery.html for more information.
+192.168.1.48 | SUCCESS => {
+    "ansible_facts": {
+        "discovered_interpreter_python": "/usr/bin/python3.11"
+    },
+    "changed": false,
+    "ping": "pong"
+}
+```
+
+## Fedora
+
+- DL Fedora Server 39 + checksum depuis <https://fedoraproject.org/server/download>
+    
+    - wget https://download.fedoraproject.org/pub/fedora/linux/releases/39/Server/x86_64/images/Fedora-Server-KVM-39-1.5.x86_64.qcow2
+    - wget https://download.fedoraproject.org/pub/fedora/linux/releases/39/Server/x86_64/images/Fedora-Server-39-1.5-x86_64-CHECKSUM
+- Vérif checksum
+
+    - curl -O https://fedoraproject.org/fedora.gpg
+    - gpgv --keyring ./fedora.gpg Fedora-Server-39-1.5-x86_64-CHECKSUM
+    - sha256sum -c Fedora-Server-39-1.5-x86_64-CHECKSUM
+- Crée VM **sans media** et avec un disque vide 8 Go
+- dans le term en étant sous `/var/lib/vz/template/qcow` : `qm importdisk 131 Fedora-Server-KVM-39-1.5.x86_64.qcow2 local-lvm` (`local` en dernier ne marche pas)
+
+**GROSSE bidouille pour faire marcher le HDD**
+
+```
+   60  qm importdisk
+   61  cd qcow/
+   62  qm importdisk 131 Fedora-Server-KVM-39-1.5.x86_64.qcow2 
+   63  qm importdisk 131 Fedora-Server-KVM-39-1.5.x86_64.qcow2 local
+   64  qm importdisk 131 Fedora-Server-KVM-39-1.5.x86_64.qcow2 local-lvm
+   65  history
+   66  pwd
+   67  qm config 131
+   # --------- Détacher le précédent ide0 ---------
+   68  qm set 131 -ide0 none
+   69  lvremove /dev/local-lvm/vm-131-disk-0
+   70  lvremove /dev/local/vm-131-disk-0
+   71  lvmdump
+   72  cd
+   73  tar tvzf lvmdump-pve-20240219163630.tgz 
+   # --------- Attacher disque importé via qm importdisk sur ide0 et le set en disk boot ---------
+   74  qm set 131 -ide0 local-lvm:vm-131-disk-1
+   75  qm set 131 -boot order=ide0
+   76  history
+```
+
+### post-install
+
+```
+hostnamectl hostname fedora-131
+```

+ 4 - 1
ansible-initial-debian-setup/ansible.cfg

@@ -1,3 +1,6 @@
 # ansible configuration file
 [defaults]
-host_key_checking = False
+host_key_checking = False
+become = True
+become_method = sudo
+become_user = root

+ 8 - 5
ansible-initial-debian-setup/inventory.ini

@@ -1,9 +1,12 @@
 ; inventory.ini - ansible inventory file
 [debian]
-192.168.1.18 ansible_user=debian
-192.168.1.85 ansible_user=debian
-192.168.1.109 ansible_user=debian
+debian-111 192.168.1.18 ansible_user=debian ansible_become=true ansible_become_method=sudo ansible_become_user=root ansible_python_interpreter=/usr/bin/python3 
+debian-112 192.168.1.85 ansible_user=debian ansible_become=true ansible_become_method=sudo ansible_become_user=root ansible_python_interpreter=/usr/bin/python3 
+debian-113 192.168.1.109 ansible_user=debian ansible_become=true ansible_become_method=sudo ansible_become_user=root ansible_python_interpreter=/usr/bin/python3 
 
 [alpine]
-192.168.1.72 ansible_user=alpine
-192.168.1.48 ansible_user=alpine
+alpine-121 192.168.1.72 ansible_user=alpine
+alpine-122 192.168.1.48 ansible_user=alpine
+
+; [fedora]
+; fedora-131 192.168.1.x

+ 1 - 1
ansible-initial-debian-setup/playbook-create-sudoers.yml

@@ -1,6 +1,6 @@
 ---
 - name: Create ansible user with sudo privileges and copy ssh key
-  hosts: new_pool
+  hosts: all
   become: true
   vars:
     sudoers_file: /etc/sudoers.d/ansible