Tâche #31751
Scénario #31564: Définir la méthode pour renommer la clé du minion
Tester le renommage du minion avec la méthode proposée
Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
Début:
25/02/2021
Echéance:
% réalisé:
100%
Restant à faire (heures):
0.0
Description
Mettre en place une infrastructure pour tester https://gist.github.com/max-arnold/8a077ae67d3ab2faaf1bef0e9094b146
Historique
#1 Mis à jour par Daniel Dehennin il y a environ 3 ans
- Statut changé de Nouveau à En cours
- Assigné à mis à Daniel Dehennin
Pour tester :
- Configurer module.run pour prendre la nouvelle syntaxe
- Créer le fichier
/srv/salt/rename_win.sls
contenant :# Save into salt://rename_win.sls then run the following command: # salt-run state.orch rename_win pillar='{"old": "OLD_NAME", "new": "NEW_NAME"}' # # For more tips like this, follow https://salt.tips {% set old_name = pillar['old'] %} {% set new_name = pillar['new'] %} Rename minion id: salt.function: - name: file.write - tgt: '{{ old_name }}' - arg: - 'C:\\salt\\conf\\minion_id' - '{{ new_name }}' Restart minion: salt.function: - name: cmd.run - tgt: '{{ old_name }}' - arg: - 'C:\\salt\\salt-call.bat service.restart salt-minion' - kwarg: bg: true - onchanges: - salt: Rename minion id Rename minion key: module.run: - file.rename: - '/etc/salt/pki/master/minions/{{ old_name }}' - '/etc/salt/pki/master/minions/{{ new_name }}' - onchanges: - salt: Rename minion id - salt: Restart minion
- Exécuter la commande suivante :
salt-run state.orch rename_win pillar='{"old": "PC-513654.dompedago.etb1.lan", "new": "PC-bidule.dompedago.etb1.lan"}'
Cela donne le résultat :
scribe.dompedago.etb1.lan_master: ---------- ID: Rename minion id Function: salt.function Name: file.write Result: True Comment: Function ran successfully. Function file.write ran on PC-513654.dompedago.etb1.lan. Started: 16:18:45.643764 Duration: 1956.698 ms Changes: PC-513654.dompedago.etb1.lan: Wrote 1 lines to "C:\\salt\\conf\\minion_id" ---------- ID: Restart minion Function: salt.function Name: cmd.run Result: True Comment: Function ran successfully. Function cmd.run ran on PC-513654.dompedago.etb1.lan. Started: 16:18:47.600851 Duration: 1971.687 ms Changes: PC-513654.dompedago.etb1.lan: ---------- ID: Rename minion key Function: module.run Result: True Comment: file.rename: True Started: 16:18:49.574036 Duration: 7.25 ms Changes: ---------- file.rename: True Summary for scribe.dompedago.etb1.lan_master ------------ Succeeded: 3 (changed=3) Failed: 0 ------------ Total states run: 3 Total run time: 3.936 s
Nous voyons ensuite la clef modifiée :
root@scribe:~# salt-key Accepted Keys: PC-bidule.dompedago.etb1.lan Denied Keys: Unaccepted Keys: Rejected Keys:
#2 Mis à jour par Daniel Dehennin il y a environ 3 ans
- Statut changé de En cours à Résolu
- % réalisé changé de 0 à 100
#3 Mis à jour par Laurent Flori il y a environ 3 ans
- Statut changé de Résolu à Fermé
- Restant à faire (heures) mis à 0.0