Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-library/pull/19#discussion_r56030258
  
    --- Diff: 
software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsiblePlaybookTasks.java
 ---
    @@ -105,5 +107,27 @@ private static String 
optionalExtraVarsParameter(Object extraVars) {
             }
             return " --extra-vars \"@" + EXTRA_VARS_FILENAME + "\" ";
         }
    +
    +    public static TaskFactory<?> setUpHostsFile(String installDir, boolean 
force) {
    +        final String hostsFile = "/etc/ansible/hosts";
    +        final String tempFile = "/tmp/hosts";
    +        String checkInstalled = !force ? "which ansible || " : "";
    +        return sshCommands(
    +                checkInstalled + " {",
    +                sudo("rm -f " + hostsFile),
    +                "echo 'localhost ansible_connection=local' > " + tempFile,
    --- End diff --
    
    I needed to write it as sudo, but when you try to do the create directly 
under sudo with a redirect, it breaks (redirects don't work under sudo).  The 
operation is still atomic really, it is the "mv"  - the tempFile is just a 
convenience.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to