All technological notes.
role
Benefits:
ansible-galaxy search role_nameInstall a role
ansible-galaxy install role_name -p ./rolesansible-config dump | grep ROLEmyrole/ ├── defaults/ # Default variables (lowest priority) │ └── main.yml ├── vars/ # Other variables (higher priority) │ └── main.yml ├── files/ # Static files to copy ├── templates/ # Jinja2 templates ├── tasks/ # Main list of tasks │ └── main.yml ├── handlers/ # Handlers triggered by notify │ └── main.yml ├── meta/ # Role dependencies and metadata │ └── main.yml └── README.md # Documentation (optional but recommended)
ansible-galaxy init role_name- name: Install and configure mysql
hosts: db-server
roles:
- mysql
- name: Install and configure mysql
hosts: db-server
roles:
- role: mysql
become: yes
vars:
mysql_user_name: db_user
roles in the playbook dir, and place all files required by the role into this dir/etc/ansible/roles