Hi everyone,
short summary: I have a playbook from where I wanna start other playbooks
hosted on Bitbucket. In short words: Got a server and want to clone
repository on Bitbucket where are all the other playbooks which I want to
run on the remote server.
---
- name: Deploy
hosts: all
become: yes
tasks:
# INSTALL GIT ON REMOTE MACHINE
- name: Install GIT
apt:
pkg:
- git
# CLONE GIT REPO ON REMOTE MACHINE
- name: Connect to Bitbucket repo
git:
repo: ssh://[email protected]/repository/repository.git
accept_hostkey: yes
version: master
dest: /home/username/git/
key_file: /home/username/.ssh/id_rsa
# FETCH YML FROM BITBUCKET
- name: Fetch yml from remote
fetch:
remote_src: yes
src: /home/username/git/playbookfolder/playbook.yml
dest: /
flat: yes
- name: Run yml
include_tasks: "/home/username/git/playbookfolder/playbook.yml"
It's cloning and saving the git repository on the host machine. But now I
want to run a playbook / include tasks on it. It's trying to find the
playbook on the Ansible controller but it should search on the remote
server I cloned the repo to. Getting this one:
PLAY [Deploy] *****************************************************
TASK [Gathering Facts]
*********************************************************
ok: [xxx.xxx.xxx.xxx]
TASK [Install GIT]
*************************************************************
ok: [xxx.xxx.xxx.xxx] => {"cache_update_time": 1550376354, "cache_updated":
false, "changed": false}
TASK [Connect to Bitbucket repo]
***********************************************
changed: [xxx.xxx.xxx.xxx] => {"after": "XXX", "before": "XXX", "changed":
true, "remote_url_changed": false}
TASK [Fetch yml from remote]
***************************************************
ok: [xxx.xxx.xxx.xxx] => {"changed": false, "checksum": "xxxxxxxxx", "dest":
"/playbook.yml", "file": "/home/username/git/playbookfolder/playbook.yml",
"md5sum": "xxxxx"}
TASK [Run yml]
*****************************************************************
fatal: [xxx.xxx.xxx.xxx]: FAILED! => {"reason": "Unable to retrieve file
contents\nCould not find or access
'/home/username/git/playbookfolder/playbook.yml' on the Ansible
Controller.\nIf you are using a module and expect the file to exist on the
remote, see the remote_src option"}
PLAY RECAP
*********************************************************************
xxx.xxx.xxx.xxx : ok=4 changed=1 unreachable=0 failed=1
I'm pretty sure I'm using the wrong syntax, but cannot figure out which is
the right one. This one here is working but it's not doing the things I
wrote in those different playbooks.
[...]
# FETCH UBUNTU / UPGRADE FROM BITBUCKET
- name: Fetch yml from remote
fetch:
remote_src: yes
src: /home/username/git/playbookfolder2/playbook1.yml
dest: /
flat: yes
import_playbook: playbook1.yml
# FETCH INSTALL LAMP FROM BITBUCKET
- name: Fetch and run other one
fetch:
remote_src: yes
src: /home/username/git/playbookfolder2/playbook2.yml
dest: /
flat: yes
import_playbook: playbook2.yml
[...]
Results here are following:
[...]
TASK [Fetch yml from remote]
***************************************************
15:19:22
34
ok: [xxx.xxx.xxx.xxx]
35
36
TASK [Fetch and run other one]
**************************************************
15:19:23
37
ok: [xxx.xxx.xxx.xxx]
38
39
PLAY RECAP
*********************************************************************
15:19:23
40
[...]
Thanks in advance for any help! :)
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/882fd5b7-6bd6-4198-9b01-fea8f5ef47a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.