patternMinor
Ansible configure and compile in directory
Viewed 0 times
directorycompileandansibleconfigure
Problem
So I have have an Ansible Task that extracts a programs sourcecode zip into a certain directory and is then supposed to compile and install it.
The extraction of the zip works fine, but then I need to execute the commands:
And these commands need to be execute from within the extracted directory. I tried several things to execute it, I couldnt get it to work.
I tried this but it fails:
``
The extraction of the zip works fine, but then I need to execute the commands:
./configure
make
sudo make installAnd these commands need to be execute from within the extracted directory. I tried several things to execute it, I couldnt get it to work.
- name: doit
command: chdir=/tmp/proftpd/ ./configure && make && make install
become: yesI tried this but it fails:
``
TASK [doit] ****
fatal: [centos]: FAILED! => {"changed": true, "cmd": ["./configure", "&&", "make", "&&", "make", "install"], "delta": "0:00:00.152824", "end": "2019-11-21 14:20:48.656070", "msg": "non-zero return code", "rc": 1, "start": "2019-11-21 14:20:48.503246", "stderr": "configure: WARNING: you should use --build, --host, --target\nconfigure: WARNING: invalid host type: &&\nconfigure: WARNING: you should use --build, --host, --target\nconfigure: WARNING: you should use --build, --host, --target\nconfigure: WARNING: invalid host type: &&\nconfigure: WARNING: you should use --build, --host, --target\nconfigure: WARNING: you should use --build, --host, --target\nInvalid configuration &&': machine &&' not recognized\nconfigure: error: /bin/sh .//config.sub && failed", "stderr_lines": ["configure: WARNING: you should use --build, --host, --target", "configure: WARNING: invalid host type: &&", "configure: WARNING: you should use --build, --host, --target", "configure: WARNING: you should use --build, --host, --target", "configure: WARNING: invalid host type: &&", "configure: WARNING: you should use --build, --host, --target", "configure: WARNING: you should use --build, --host, --target", "Invalid configuration &&': machine `&&' not recognized", "configure: error: /bin/sh .//config.sub && failed"], "stdout": "checking build system type... ", "stdout_lines": ["chSolution
Ansible
You should probably split the task up into three:
This should yield the same actual result, but would be more likely to be idempotent.
command module requires only one command and cannot be changed. You should use the shell module at the very least. Note however that this will break the idempotency of the playbook.You should probably split the task up into three:
- configure task using the
shellmodule. Usecreates:to tell the task to be skipped if the configure task has already created the expected output file
- make task, using the Ansible Make module
- similarly for the make install task.
This should yield the same actual result, but would be more likely to be idempotent.
Context
StackExchange DevOps Q#9881, answer score: 4
Revisions (0)
No revisions yet.