How to automatically install Ansible Galaxy roles?

前端 未结 8 553
借酒劲吻你
借酒劲吻你 2020-12-07 07:50

All my Ansible playbooks/roles are checked in to my git repo.

However, for Ansible Galaxy roles I always have to explicitly download them one by one on every machine

8条回答
  •  醉梦人生
    2020-12-07 08:46

    Here, my requirements are on the role and used in install.yml

    main.yml

     # tasks file for MY_ROLE
    - name: Install requirements
      local_action: command ansible-galaxy install -r {{ role_path }}/requirements.yml -p /etc/ansible/roles
    
    - include_tasks: install.yml 
    
    .  
    ├── playbook.yml  
    ├── inventory  
    ├── roles  
    │    └── My_Role   
    │        ├── tasks  
    │        │   └── main.yml  
    │        │   └── install.yml  
    │        └── requirements.yml
    

提交回复
热议问题