resolved issue with ENV vars when using become inside/outside of play
diff --git a/roles/head-prep/tasks/main.yml b/roles/head-prep/tasks/main.yml
index d0638b6..7755eba 100644
--- a/roles/head-prep/tasks/main.yml
+++ b/roles/head-prep/tasks/main.yml
@@ -48,17 +48,17 @@
- name: Prepare user account and generate SSH key
user:
- name={{ ansible_env['SUDO_USER'] }}
+ name={{ ansible_user_id }}
generate_ssh_key=yes
groups="libvirtd" append=yes
- name: Get public key
- shell: cat {{ ansible_env['PWD'] }}/.ssh/id_rsa.pub
+ shell: cat {{ ansible_user_dir }}/.ssh/id_rsa.pub
register: sshkey
- name: Add key to this user account
authorized_key:
- user={{ ansible_env['SUDO_USER'] }}
+ user={{ ansible_user_id }}
key="{{ sshkey.stdout }}"
- name: Copy keypair to /tmp
diff --git a/roles/juju-setup/tasks/main.yml b/roles/juju-setup/tasks/main.yml
index 0540b1c..c183d9b 100644
--- a/roles/juju-setup/tasks/main.yml
+++ b/roles/juju-setup/tasks/main.yml
@@ -30,4 +30,5 @@
- name: Add Juju status to ansible facts
set_fact: juju_status="{{ juju_status_json.stdout | from_json }}"
-
+- name: Add machines to Juju
+ with_items: head_vm_list
diff --git a/roles/juju-user-prep/tasks/main.yml b/roles/juju-user-prep/tasks/main.yml
index 27f1d91..6f675fd 100644
--- a/roles/juju-user-prep/tasks/main.yml
+++ b/roles/juju-user-prep/tasks/main.yml
@@ -3,7 +3,7 @@
- name: Disable host key checking in ~/.ssh/config
lineinfile:
- dest={{ ansible_env['PWD'] }}/.ssh/config
+ dest={{ ansible_user_dir }}/.ssh/config
line="StrictHostKeyChecking no"
create=yes
mode=0600
@@ -11,5 +11,5 @@
- name: Disable host key checking in ~/.ansible.cfg
copy:
src=ansible.cfg
- dest={{ ansible_env['PWD'] }}/.ansible.cfg
+ dest={{ ansible_user_dir }}/.ansible.cfg