Have ansible role retrieve its files from external location as part of its own role -
so 1 thing we've encountered in our project not want store our large files in our git repo our ansible roles because slows down cloning (and git limits files 100 mb anyways).
what we've done store our files in separate internal location, our files can sit statically , have no size restrictions. our roles written first pull these static files local files folder , continue normal.
i.e. roles/foo/tasks/main.yml
- name: create role's files directory file: path: "{{roles_files_directory}}" state: directory - name: copy static foo local get_url: url: "{{foo_static_gz}}" dest: "{{roles_files_directory}}/{{foo_gz}}" #....do rest of tasks... roles/foo/vars/main.yml
roles_files_directory: "/some/path/roles/foo/files" foo_static_gz: "https://internal.foo.tar.gz" foo_gz: "foo.tar.gz" the main thing don't find sound hard coded path role's files directory. preferably dynamically path when running ansible, haven't been able find documentation on that. issue can arise because different users may check roles different root paths. know how dynamically know role path, or have other pattern solves overall problem?
edit:
i discovered there's {{playbook_dir}} variable return "/some/path", might dynamic enough in case. still isn't safe against situation role name might change, that's way rarer occurrence , can handled through version control.
what passing values command line?
--- - hosts: '{{ hosts }}' remote_user: '{{ user }}' tasks: - ... ansible-playbook release.yml --extra-vars "hosts=vipers user=starbuck" http://docs.ansible.com/playbooks_variables.html#passing-variables-on-the-command-line
Comments
Post a Comment