Ziel: Angesichts eines Debian-Servers ohne installiertes Python (und einiger anderer fehlender ansible-Voraussetzungen) benutze ansible, um sie zu installieren, damit ich dann die normalen ansible-Module verwenden kann (fast alle erfordern Python), um den Server bereitzustellen.Bootstrapping ansible Voraussetzungen mit dem Script-Modul. Python benötigt?
Nach the ansible documentation for the "script" module „Dieses Modul benötigt keinen Python auf dem Remote-System, ähnlich wie die Rohmodul.“. Allerdings basiert auf meinen Tests scheint es wie das Skriptmodul Versuch in der Tat Python auf dem Remote-System, zumindest wenn die sudo
Option wahr ist, ausgeführt werden. Ich glaube, ich kann bekommen so lange wie mit dem Skriptmodul zu arbeiten, wie ich nicht aktivieren sudo
Option des ansible, aber dann muss ich meine Remote-Benutzer sudo Erlaubnis ohne Passwortabfrage haben oder mein Skript ist nur für interaktive Warte gehen zu hängen Eingabe des sudo-Passwortes
Also meine Frage ist: A) Was ist der Deal mit dem „Script“ -Modul ist. Benötigt es Python auf dem Remote-System oder nicht?
und B) Gibt es einen besseren Weg, um mein größeres Ziel zu erreichen, die Bereitstellung vollständig ohne manuelle Schritte vor ansible automatisierte selbst verwendet werden kann?
Hier ist meine Ausgabe von ansible-playbook -vvv
, die zeigt, es läuft /usr/bin/python
auf dem Remote-System, und es gibt keine Datei dort, weil Python noch nicht installiert ist.
TASK: [install ansible prerequisites]
***************************************** <10.9.8.31> ESTABLISH
CONNECTION FOR USER: plyons <10.9.8.31> EXEC ['ssh', '-C', '-tt',
'-q', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s',
'-o', 'ControlPath=/Users/plyons/.ansible/cp/ansible-
ssh-%h-%p-%r', '-o', 'StrictHostKeyChecking=no', '-o',
'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications
=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o',
'PasswordAuthentication=no', '-o', 'ConnectTimeout=10',
'10.9.8.31', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-
tmp-1396233547.35-182235573044157 && chmod a+rx $HOME/.ansible/tmp
/ansible-tmp-1396233547.35-182235573044157 && echo
$HOME/.ansible/tmp/ansible-tmp-1396233547.35-182235573044157'"]
<10.9.8.31> PUT
/var/folders/n4/8skjkv9s5hbc4t5r0tr0xrk80000gn/T/tmpT1Vh6e TO
/home/plyons/.ansible/tmp/ansible-
tmp-1396233547.35-182235573044157/stat <10.9.8.31> EXEC ['ssh',
'-C', '-tt', '-q', '-o', 'ControlMaster=auto', '-o',
'ControlPersist=60s', '-o', 'ControlPath=/Users/plyons/.ansible/cp
/ansible-ssh-%h-%p-%r', '-o', 'StrictHostKeyChecking=no', '-o',
'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications
=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o',
'PasswordAuthentication=no', '-o', 'ConnectTimeout=10',
'10.9.8.31', '/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via
ansible, key=hyplatqjmvybpfqtukjegkibbuyrnoqj] password: " -u root
/bin/sh -c \'"\'"\'echo SUDO-SUCCESS-
hyplatqjmvybpfqtukjegkibbuyrnoqj; /usr/bin/python
/home/plyons/.ansible/tmp/ansible-
tmp-1396233547.35-182235573044157/stat\'"\'"\'\'']
Hier ist mein Textbuch Aufgabe:
tasks:
-
name: install ansible prerequisites
script: ansible_prereqs.sh creates=/root/.ansible_prereqs_installed
Und das ansible_prereqs.sh Skript:
#!/bin/sh
#install ansible prereqs manually or all apt-based ansible commands will fail
# http://euphonious-intuition.com/2013/01/bootstrapping-a-cluster-with-ansible-debian-6-and-oracle-java-7/
apt-get update
apt-get install -y python python-apt python-pycurl sshpass
touch /root/.ansible_prereqs_installed
Dies hilft. Die Zeile 'changed_when' scheint ungültig zu sein. YAML und ansible zeigen einen Syntaxfehler bezüglich der Anführungszeichen. –
Ich änderte die Zitate sollten funktionieren – DomaNitro
Register fehlte ein Doppelpunkt und dies machte die changed_when aussehen wie das Problem - jetzt behoben. –