I set ansible_become in my hosts file because I do most things as root when setting up a new machine.
all:
hosts:
ganymede:
ansible_host: ganymede.xcv.org
vars:
ansible_user: ubuntu
ansible_become: yes
ansible_become_user: root
I require the git repo to be cloned as the service account and I cannot figure out how to make that happen
- name: Git
vars:
ansible_become: no
block:
- name: whoami
command: whoami
register: a
- debug:
msg: {{ a.stdout }}
- git:
repo: "git@github.com:fakerepo/ganymede.git"
dest: "/opt/"
force: yes
key_file: ~ganymede/.ssh/id_ed25519
become: yes
become_user: ganymede
Unsetting ansible_become appears to work because the user is ubuntu.
Setting become and become_user has no effect and I want to know what it takes for that to work so that git works correctly.
TASK [debug] ***********************************************
ok: [ganymede] => {
"msg": "ubuntu"
}
TASK [git] *************************************************
fatal: [ganymede]: FAILED! => {
"changed": false,
"cmd": "/usr/bin/git ls-remote git@github.com:fakerepo/ganymede.git -h refs/heads/HEAD",
"msg":
"Warning: Identity file /home/ganymede/.ssh/id_ed25519 not accessible: Permission denied."
"Host key verification failed."
"fatal: Could not read from remote repository."
"Please make sure you have the correct access rights and the repository exists.",
"rc": 128,
"stderr":
"Warning: Identity file /home/ganymede/.ssh/id_ed25519 not accessible: Permission denied."
"Host key verification failed."
"fatal: Could not read from remote repository."
"Please make sure you have the correct access rights and the repository exists.",
"stderr_lines": [
"Warning: Identity file /home/ganymede/.ssh/id_ed25519 not accessible: Permission denied.",
"Host key verification failed.",
"fatal: Could not read from remote repository.",
"",
"Please make sure you have the correct access rights and the repository exists."
],
"stdout": "",
"stdout_lines": []
}