in Education by
I have a playbook that looks like the following. It is supposed to install python onto the remote machine so that it can start using modules, hence why I have it using raw since it is the only thing that will run without a python interpreter. --- - name: Checking Ansible Python Dependency hosts: Debian_Buster gather_facts: False tasks: - name: install python 2 become: yes raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) This playbook task works as expected, but always returned "changed", even when nothing was installed. Is there a way i can make this playbook return "ok" when test -e /usr/bin/python returns 0, and then return 'changed' when test -e /usr/bin/python returns 1? Note: I can not use any other module other than raw because the python dependency is not available. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The basic solution to this kind of problem makes use of the register keyword to save the result of the task, and then inspect the result in a changed_when expression. In your case, we cannot use the return code alone to decide this, but we could just inspect the standard output, which, correct me if I am wrong, should only be empty if the test command succeeded. Example: - name: install python 2 become: yes raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) register: command_result changed_when: command_result.stdout | length > 0

Related questions

0 votes
    I am new at using Ansible. I tried to create directories and download files using Ansible. Should I use shell ... module is available? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    My git workspace is dirty, there are some local modifications. When I use the command git pull origin master it ... Ansible git module? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I'm just getting my feet wet with Ansible 2.2 and Devops and I've run into the following problem. I have a ... . How to fix this? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    If I have to build an infrastructure stack in the cloud using a tool like Ansible. Is it necessary to have the ... the best to use? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    How to keep data secret in a Ansible playbook?...
asked Jan 29, 2023 in Technology by JackTerrance
0 votes
    How to Install Nginx using Ansible playbook?...
asked Jul 29, 2021 in Technology by JackTerrance
0 votes
    Which command tells ansible to run the playbook on all the hosts except host1? (i)ansible-playbook playbooks/ ... ansible-playbook playbooks/PLAYBOOK_NAME.yml -limit 'all:!host1'...
asked Jan 25, 2023 in Technology by JackTerrance
0 votes
    I would like to get a list of Python modules, which are in my Python installation (UNIX server). How can ... in your computer? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    make a list of all the software installed on any computer of the computer lab or that computer allotted to you in the lab Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    I know a little of Python and more than a year ago I wrote a small script, using pipenv to manage the ... 3.0 should work. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    In my Application I am not having any UI part, so I need to start a Service as soon as the ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    URL is http://*.*.*.*/100/?id=1&version=1 params is {"cityId": "110000", "query": {" ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 27, 2022 in Education by JackTerrance
0 votes
    I have a helper method that shows an ContentDialog with an input box that accepts string data. My issue ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I want to be able to compare an image taken from a webcam to an image stored on my computer. The ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    On a button click, I am using the below code testViewController *myWindowController = [[testViewController alloc] ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
...