roles_path
,是否已設定 /home/deyu1/ansible/roles 目錄。
[deyu1@kvm19 ansible]$ vim ansible.cfg [deyu1@kvm19 ansible]$ grep ^roles_path ansible.cfg roles_path = /home/deyu1/ansible/roles
[deyu1@kvm19 ansible]$ mkdir roles/
[deyu1@kvm19 ansible]$ cd roles/ [deyu1@kvm19 roles]$ pwd /home/deyu1/ansible/roles
[deyu1@kvm19 roles]$ ansible-galaxy role init apache - Role apache was created successfully
[deyu1@kvm19 roles]$ tree apache/ apache/ ├── defaults │ └── main.yml ├── files ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── README.md ├── tasks │ └── main.yml ├── templates ├── tests │ ├── inventory │ └── test.yml └── vars └── main.yml 8 directories, 8 files
[deyu1@kvm19 ansible]$ cd .. [deyu1@kvm19 ansible]$ ansible-galaxy role list # /home/deyu1/ansible/roles - apache, (unknown version)