以下是簡易的範例,透過 unix find 指令,找尋剛製作好的 package ,把它記錄在變數中:
$ mkdir -p ansible-test/roles && cd ansible-test && ansible-galaxy install changyy.find-package -p roles/
- downloading role 'find-package', owned by changyy
- downloading role from https://github.com/changyy/ansible-role-find-package/archive/master.tar.gz
- extracting changyy.find-package to roles/changyy.find-package
- changyy.find-package was installed successfully
$ vim test.yml
---
- hosts: localhost
roles:
- { role: changyy.find-package, package_dir: "/data/rpm/production/" , package_name_prefix: "package-*" }
- hosts: 127.0.0.1
tasks:
- name: copy package
copy: src="{{hostvars['localhost']['package_path']}}" dest=/tmp
$ ansible-playbook test.yml
連續動作還可以發佈至指定機器上,詳情請見:https://github.com/changyy/ansible-role-find-package
沒有留言:
張貼留言