How can I pass a relative path so that Ansible can copy files from node/keys
and copy them to a server?
The playbook is ansible/playbook
.
My directory structure is:
├── ansible
│ ├── inventory
│ └── playbook
├── node
│ ├── keys
│ ├── index.js
│ ├── node_modules
│ ├── package-lock.json
│ └── utils
└── shell
├── data.json
├── create-data.sh
├── destory.sh
└── firewall-rules.sh
Below is the playbook:
- hosts: all
vars:
source: "{{ source }}"
destination: /home/ubuntu
tasks:
- name: Copy files
copy:
src: "{{ source }}"
dest: "{{ destination }}"
That's how I run:
ansible-playbook -i inventory/inventory.yaml playbook/crypto-generate.yaml
--extra-vars "source=../node/keys"
I am trying to pass a relative path.
I am using {{ playbook_dir }}
to construct full path,see
special ansible variables
- name: Copy files
copy:
src: "{{ playbook_dir }}/../../node/keys"
dest: "{{ destination }}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With