Skip to content

Instantly share code, notes, and snippets.

@jgornick
Last active June 8, 2023 16:13
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgornick/9962043 to your computer and use it in GitHub Desktop.
Save jgornick/9962043 to your computer and use it in GitHub Desktop.
Ansible: ./configure, make, make install
# 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
@jmcbee
Copy link

jmcbee commented May 2, 2015

Don't do this. if one of the command fails it will still continue running the other commands on the list.

@rnwolf
Copy link

rnwolf commented Jun 25, 2015

@fbm-static what is the better way of doing this?

@jnlickey
Copy link

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/'

@ayinla
Copy link

ayinla commented Feb 17, 2016

shell: cd DIR && ./configure --prefix={{ installation_prefix }} && make && make install
if one step fails, it doesn't proceed

@lakshmantgld
Copy link

How to make configure, make, make install idempotent using ansible??

@mariusmuja
Copy link

You can make it idempotent using the "creates" argument.

@eenblam
Copy link

eenblam commented Aug 25, 2016

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.

@yuswitayudi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment