# This works | |
- name: Install unixODBC | |
command: sudo {{ item }} chdir="/tmp/{{ mysql_odbc_unixodbc_url | basename | replace('.tar.gz', '') }}" | |
with_items: | |
- ./configure --prefix=/usr/local | |
- make | |
- make install | |
# This _doesn't_ work | |
# Why doesn't the chdir option get recognized? | |
- name: Install unixODBC | |
command: | |
chdir: "/tmp/{{ mysql_odbc_unixodbc_url | basename | replace('.tar.gz', '') }}" | |
free_form: "sudo {{ item }}" | |
with_items: | |
- ./configure --prefix=/usr/local | |
- make | |
- make install |
@fbm-static what is the better way of doing this?
The following worked for me, and stops if the .configure, make, or make install breaks! I also know that I could have just used the command function for all of them, but I was trying to learn how the with_items function works. Hope this helps someone else!
#- name: Installing FFMPEG
- name: Running ./configure for FFMPEG
command: '"{{ item }}" chdir=/myhome/ffmpeg-2.8.2/'
with_items:
- ./configure
- name: Running "make" for FFMPEG
command: '"{{ item }}" chdir=/myhome/ffmpeg-2.8.2/'
with_items:
- make
- name: Running "make install" for FFMPEG
command: 'make install chdir=/myhome/ffmpeg-2.8.2/'
shell: cd DIR && ./configure --prefix={{ installation_prefix }} && make && make install
if one step fails, it doesn't proceed
How to make configure, make, make install idempotent using ansible??
You can make it idempotent using the "creates" argument.
Check out this task file to see Git built from source using Ansible. It uses creates
as @mariusmuja suggests, but it also makes heavy use of Ansible's facts to store state.
The following worked for me, and stops if the .configure, make, or make install breaks! I also know that I could have just used the command function for all of them, but I was trying to learn how the with_items function works. Hope this helps someone else!
#- name: Installing FFMPEG - name: Running ./configure for FFMPEG command: '"{{ item }}" chdir=/myhome/ffmpeg-2.8.2/' with_items: - ./configure - name: Running "make" for FFMPEG command: '"{{ item }}" chdir=/myhome/ffmpeg-2.8.2/' with_items: - make - name: Running "make install" for FFMPEG command: 'make install chdir=/myhome/ffmpeg-2.8.2/'
Nice, this worked for me. Very helpful, thankyou
Don't do this. if one of the command fails it will still continue running the other commands on the list.