brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [3/4] brooklyn-library git commit: Simplifications following review, use a simpler means of writing the hosts file.
Date Fri, 18 Mar 2016 23:26:01 GMT
Simplifications following review, use a simpler means of writing the hosts file.


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-library/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-library/commit/824dc199
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-library/tree/824dc199
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-library/diff/824dc199

Branch: refs/heads/master
Commit: 824dc199a7ba1b2bcd114b388f43fed9c874a85f
Parents: 7e97a26
Author: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Authored: Mon Mar 14 16:52:41 2016 +0000
Committer: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Committed: Mon Mar 14 17:48:51 2016 +0000

----------------------------------------------------------------------
 .../ansible/AnsibleLifecycleEffectorTasks.java  |  2 +-
 .../entity/cm/ansible/AnsiblePlaybookTasks.java | 20 +++-----------------
 2 files changed, 4 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/824dc199/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsibleLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsibleLifecycleEffectorTasks.java
b/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsibleLifecycleEffectorTasks.java
index ccf8303..fd73c61 100644
--- a/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsibleLifecycleEffectorTasks.java
+++ b/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsibleLifecycleEffectorTasks.java
@@ -118,7 +118,7 @@ public class AnsibleLifecycleEffectorTasks extends MachineLifecycleEffectorTasks
         }
 
         DynamicTasks.queue(AnsiblePlaybookTasks.installAnsible(installDir, false));
-        DynamicTasks.queue(AnsiblePlaybookTasks.setUpHostsFile(installDir, false));
+        DynamicTasks.queue(AnsiblePlaybookTasks.setUpHostsFile(false));
 
         if (getExtraVars() != null) {
             DynamicTasks.queue(AnsiblePlaybookTasks.configureExtraVars(getRunDir(), extraVars,
false));

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/824dc199/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsiblePlaybookTasks.java
----------------------------------------------------------------------
diff --git a/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsiblePlaybookTasks.java
b/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsiblePlaybookTasks.java
index 0589ee7..d9f11c2 100644
--- a/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsiblePlaybookTasks.java
+++ b/software/cm/ansible/src/main/java/org/apache/brooklyn/entity/cm/ansible/AnsiblePlaybookTasks.java
@@ -108,26 +108,12 @@ public class AnsiblePlaybookTasks {
         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,
-                sudo("mv " + tempFile + " " + hostsFile),
-                "}"
-            )
+    public static TaskFactory<?> setUpHostsFile(boolean force) {
+        String checkInstalled = !force ? "grep localhost.ansible_connection=local /etc/ansible/hosts
|| " : "";
+        return ssh(checkInstalled + sudo("echo 'localhost ansible_connection=local' | sudo
tee /etc/ansible/hosts"))
             .requiringExitCodeZero()
             .summary("write hosts file");
     }
 
-
-    public static SshEffectorTasks.SshEffectorTaskFactory<Integer> sshCommands(String
line, String... lines) {
-        final MutableList.Builder<String> builder = MutableList.<String>builder().add(line);
-        builder.addAll(lines);
-        return ssh(Strings.join(builder.build(), "\n"));
-    }
 }
 


Mime
View raw message