How to make ansible return “ok” when python is installed in this playbook?bootstrapping ansible prerequisites with the script module. python required?How do I make an idempontent shell in AnsibleRunning Ansible Playbooks under uWSGI not workingUnable to run Ansible API with PlayBook classInstalling specific apt version with ansibleVagrant ansible provisioner throwing error 'MODULE FAILURE' when running playbookAnsible playbook - permission deniedRun Same Ansible Playbook for Different Local UsersAnsible doesn't see an installed Python moduleAnsible executing playbook boto missing

Can you make an identity from this product?

Wizard clothing for warm weather

How far would a landing Airbus A380 go until it stops with no brakes?

Analogy between an unknown in an argument, and a contradiction in the principle of explosion

What are the unintended or dangerous consequences of allowing spells that target and damage creatures to also target and damage objects?

Why ambiguous grammars are bad?

A Salute to Poetry

How to befriend someone who doesn't like to talk?

Rail-to-rail op-amp only reaches 90% of VCC, works sometimes, not everytime

Use 1 9 6 2 in this order to make 75

Oil draining out shortly after turbo hose detached/broke

Does a (nice) centerless group always have a centerless profinite completion?

What do you call the action of "describing events as they happen" like sports anchors do?

How was the airlock installed on the Space Shuttle mid deck?

Was planting UN flag on Moon ever discussed?

Can the removal of a duty-free sales trolley result in a measurable reduction in emissions?

Is it okay to have a sequel start immediately after the end of the first book?

The significance of kelvin as a unit of absolute temperature

Is it a acceptable way to write a loss function in this form?

Was Self-modifying-code possible just using BASIC?

As easy as Three, Two, One... How fast can you go from Five to Four?

What is the Leave No Trace way to dispose of coffee grounds?

Housemarks (superimposed & combined letters, heraldry)

Could a person damage a jet airliner - from the outside - with their bare hands?



How to make ansible return “ok” when python is installed in this playbook?


bootstrapping ansible prerequisites with the script module. python required?How do I make an idempontent shell in AnsibleRunning Ansible Playbooks under uWSGI not workingUnable to run Ansible API with PlayBook classInstalling specific apt version with ansibleVagrant ansible provisioner throwing error 'MODULE FAILURE' when running playbookAnsible playbook - permission deniedRun Same Ansible Playbook for Different Local UsersAnsible doesn't see an installed Python moduleAnsible executing playbook boto missing






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















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.










share|improve this question






























    1















    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.










    share|improve this question


























      1












      1








      1








      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.










      share|improve this question
















      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.







      ansible yaml






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 21:51









      Anthon

      34.3k17101159




      34.3k17101159










      asked Mar 24 at 21:45









      TrevorKSTrevorKS

      85




      85






















          1 Answer
          1






          active

          oldest

          votes


















          1














          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





          share|improve this answer

























          • Exactly what i needed. I found the changed_when option and got it to work, but my play was much longer than yours. Thank you for showing me best practice :)

            – TrevorKS
            Mar 27 at 0:27











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328884%2fhow-to-make-ansible-return-ok-when-python-is-installed-in-this-playbook%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          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





          share|improve this answer

























          • Exactly what i needed. I found the changed_when option and got it to work, but my play was much longer than yours. Thank you for showing me best practice :)

            – TrevorKS
            Mar 27 at 0:27















          1














          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





          share|improve this answer

























          • Exactly what i needed. I found the changed_when option and got it to work, but my play was much longer than yours. Thank you for showing me best practice :)

            – TrevorKS
            Mar 27 at 0:27













          1












          1








          1







          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





          share|improve this answer















          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






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 25 at 0:35

























          answered Mar 25 at 0:05









          Thomas HirschThomas Hirsch

          1,099822




          1,099822












          • Exactly what i needed. I found the changed_when option and got it to work, but my play was much longer than yours. Thank you for showing me best practice :)

            – TrevorKS
            Mar 27 at 0:27

















          • Exactly what i needed. I found the changed_when option and got it to work, but my play was much longer than yours. Thank you for showing me best practice :)

            – TrevorKS
            Mar 27 at 0:27
















          Exactly what i needed. I found the changed_when option and got it to work, but my play was much longer than yours. Thank you for showing me best practice :)

          – TrevorKS
          Mar 27 at 0:27





          Exactly what i needed. I found the changed_when option and got it to work, but my play was much longer than yours. Thank you for showing me best practice :)

          – TrevorKS
          Mar 27 at 0:27



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328884%2fhow-to-make-ansible-return-ok-when-python-is-installed-in-this-playbook%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript