Commit 39501b53 authored by Łukasz Nowak's avatar Łukasz Nowak

ansible: Use slapos-ansible

Reexecute playbooks with same executable or just use
/opt/slapos-ansible-bin/ansible{,-playbook}
parent a46f452a
...@@ -30,7 +30,7 @@ How to build all VMs? ...@@ -30,7 +30,7 @@ How to build all VMs?
You can use ansible for build all VMs locally, and gzip them: You can use ansible for build all VMs locally, and gzip them:
ansible-playbook build.yml -i localhost, /opt/slapos-ansible/bin/ansible-playbook build.yml -i localhost,
How to upload to shacache? How to upload to shacache?
-------------------------- --------------------------
...@@ -42,7 +42,7 @@ eventually, update shacache/shacache.cfg. ...@@ -42,7 +42,7 @@ eventually, update shacache/shacache.cfg.
BE CAREFULL, every time you run this command you upload the files to shacache, BE CAREFULL, every time you run this command you upload the files to shacache,
even if the files are there already. even if the files are there already.
ansible-playbook upload.yml -i localhost, /opt/slapos-ansible/bin/ansible-playbook upload.yml -i localhost,
How can I check if all images are on shacache? How can I check if all images are on shacache?
---------------------------------------------- ----------------------------------------------
......
...@@ -24,7 +24,7 @@ How to build VM with differents images size? ...@@ -24,7 +24,7 @@ How to build VM with differents images size?
3) Use ansible to build all VMs and compress them in local folder 3) Use ansible to build all VMs and compress them in local folder
ansible-playbook build-vm-bootstrap.yml -i hosts /opt/slapos-ansible/bin/ansible-playbook build-vm-bootstrap.yml -i hosts
After build, images are generated in folder output-DISTRO-XXG-vm-boostrapn, they are gziped to reduce the size when downloading images. After build, images are generated in folder output-DISTRO-XXG-vm-boostrapn, they are gziped to reduce the size when downloading images.
...@@ -37,7 +37,7 @@ How to upload images to shacache ...@@ -37,7 +37,7 @@ How to upload images to shacache
To build and upload images to shacache, use this ansible command To build and upload images to shacache, use this ansible command
UPLOAD=yes ansible-playbook build-vm-bootstrap.yml -i hosts UPLOAD=yes /opt/slapos-ansible/bin/ansible-playbook build-vm-bootstrap.yml -i hosts
A file URL.txt will be generated with url as well as MD5SUM to download each image from shacache. A file URL.txt will be generated with url as well as MD5SUM to download each image from shacache.
......
...@@ -7,7 +7,7 @@ export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ...@@ -7,7 +7,7 @@ export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
for i in `seq 1 10`; do for i in `seq 1 10`; do
echo "Try $i" echo "Try $i"
ansible-playbook {{ startup_playbook_id }} -i hosts --connection=local {{ ansible_env['_'] }} {{ startup_playbook_id }} -i hosts --connection=local
if [ "$?" == 0 ]; then if [ "$?" == 0 ]; then
exit 0 exit 0
fi fi
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
job="usr/local/bin/log-uploader" job="usr/local/bin/log-uploader"
- name: run ansible playbook - name: run ansible playbook
shell: ansible-playbook "{{ lookup('file', '/tmp/playbook_software_name') }}" -i hosts shell: "{{ ansible_env['_'] }} {{ lookup('file', '/tmp/playbook_software_name') }}" -i hosts
# install dependencies # install dependencies
- easy_install: name=pip - easy_install: name=pip
......
...@@ -58,13 +58,13 @@ ...@@ -58,13 +58,13 @@
current_upgrade_signature current_upgrade_signature
- name: Do upgrade - name: Do upgrade
shell: ansible-playbook {{ upgrader_playbook }} -i hosts 2>>/opt/upgrader/latest_upgrade.log >> /opt/upgrader/latest_upgrade.log shell: {{ ansible_env['_'] }} {{ upgrader_playbook }} -i hosts 2>>/opt/upgrader/latest_upgrade.log >> /opt/upgrader/latest_upgrade.log
when: (upgrade_after > lookup('file', '/opt/upgrader/last-upgrade')|int ) and (lookup('file', '/opt/upgrader/next-upgrade-signature') != lookup('file', '/opt/upgrader/current-upgrade-signature')) when: (upgrade_after > lookup('file', '/opt/upgrader/last-upgrade')|int ) and (lookup('file', '/opt/upgrader/next-upgrade-signature') != lookup('file', '/opt/upgrader/current-upgrade-signature'))
args: args:
chdir: /opt/upgrader/playbook-tmp/ chdir: /opt/upgrader/playbook-tmp/
- name: Set Cron - name: Set Cron
cron: name="Launch Upgrader with ansible" minute="0" hour="*/3" job='rm -rf /opt/upgrader/playbook && cp -R /opt/upgrader/playbook-tmp /opt/upgrader/playbook && cd /opt/upgrader/playbook && PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin ansible-playbook upgrader-run.yml --extra-vars "upgrader_playbook={{ upgrader_playbook }}" -i hosts 2>>/opt/upgrader/latest_upgrade.log >> /opt/upgrader/latest_upgrade.log' cron: name="Launch Upgrader with ansible" minute="0" hour="*/3" job='rm -rf /opt/upgrader/playbook && cp -R /opt/upgrader/playbook-tmp /opt/upgrader/playbook && cd /opt/upgrader/playbook && PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin {{ ansible_env['_'] }} upgrader-run.yml --extra-vars "upgrader_playbook={{ upgrader_playbook }}" -i hosts 2>>/opt/upgrader/latest_upgrade.log >> /opt/upgrader/latest_upgrade.log'
- cron: name="Launch Upgrader" state=absent - cron: name="Launch Upgrader" state=absent
......
...@@ -29,5 +29,5 @@ ...@@ -29,5 +29,5 @@
shell: echo "TODO" shell: echo "TODO"
- name: Set Cron - name: Set Cron
cron: name="Launch Startup with ansible" special_time=reboot job='cd /opt/upgrader/playbook && ansible-playbook vifib-startup.yml -i hosts 2>>/opt/upgrader/startup.log >> /opt/upgrader/startup.log' cron: name="Launch Startup with ansible" special_time=reboot job='cd /opt/upgrader/playbook && {{ ansible_env['_'] }} vifib-startup.yml -i hosts 2>>/opt/upgrader/startup.log >> /opt/upgrader/startup.log'
...@@ -11,4 +11,4 @@ echo "Sleeping for $WAIT_TIME seconds..." ...@@ -11,4 +11,4 @@ echo "Sleeping for $WAIT_TIME seconds..."
sleep $WAIT_TIME sleep $WAIT_TIME
# Reduce priority of Ansible rerun # Reduce priority of Ansible rerun
nice -19 chrt --idle 0 ionice -c3 ansible-playbook {{ startup_playbook_id }} -i hosts --connection=local nice -19 chrt --idle 0 ionice -c3 {{ ansible_env['_'] }} {{ startup_playbook_id }} -i hosts --connection=local
...@@ -87,7 +87,7 @@ echo "done." ...@@ -87,7 +87,7 @@ echo "done."
echo -n "Instantiating ERP5 instance..." echo -n "Instantiating ERP5 instance..."
for i in `seq 10` ; do for i in `seq 10` ; do
ansible-playbook --extra-vars @extra_vars.yml /opt/slapos.playbook/$PLAYBOOK >> $LOG_FILE 2>&1 /opt/slapos-ansible/bin/ansible-playbook --extra-vars @extra_vars.yml /opt/slapos.playbook/$PLAYBOOK >> $LOG_FILE 2>&1
ANSIBLE_RESULT=$? ANSIBLE_RESULT=$?
if [ "$ANSIBLE_RESULT" == "0" ] ; then if [ "$ANSIBLE_RESULT" == "0" ] ; then
break break
...@@ -109,4 +109,4 @@ else ...@@ -109,4 +109,4 @@ else
echo "/opt/slapos/log/slapos-node-instance.log:" >> $LOG_FILE 2>&1 echo "/opt/slapos/log/slapos-node-instance.log:" >> $LOG_FILE 2>&1
cat /opt/slapos/log/slapos-node-instance.log >> $LOG_FILE 2>&1 cat /opt/slapos/log/slapos-node-instance.log >> $LOG_FILE 2>&1
exit 1 exit 1
fi fi
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment