[student@workstation dev-roles]$ vi install-roles.yml [student@workstation dev-roles]$ cat install-roles.yml --- # install-role.yml - src: http://materials.example.com/roles-library/student.bash_env.tgz name: student.bash_env [student@workstation dev-roles]$ ansible-galaxy install -p roles -r install-roles.yml - downloading role from http://materials.example.com/roles-library/student.bash_env.tgz - extracting student.bash_env to roles/student.bash_env - student.bash_env was installed successfully [student@workstation dev-roles]$ tree . ├── ansible.cfg ├── install-roles.yml ├── inventory ├── roles │ ├── myfirewall │ │ ├── defaults │ │ │ └── main.yml │ │ ├── handlers │ │ │ └── main.yml │ │ └── tasks │ │ └── main.yml │ ├── myvhost │ │ ├── files │ │ │ └── html │ │ │ └── index.html │ │ ├── handlers │ │ │ └── main.yml │ │ ├── meta │ │ │ └── main.yml │ │ ├── tasks │ │ │ └── main.yml │ │ └── templates │ │ └── vhost.conf.j2 │ └── student.bash_env │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── handlers │ │ └── main.yml │ ├── meta │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ ├── templates │ │ ├── _bash_profile.j2 │ │ ├── _bashrc.j2 │ │ └── _vimrc.j2 │ ├── tests │ │ ├── inventory │ │ └── test.yml │ └── vars │ └── main.yml └── use-vhost-role.yml [student@workstation dev-roles]$ vi use-bash_env-role.yml [student@workstation dev-roles]$ cat use-bash_env-role.yml --- - name: use student.bash_env role playbook hosts: webservers user: devops become: true roles: - student.bash_env [student@workstation dev-roles]$ ansible-playbook -i inventory use-bash_env-role.yml PLAY [use student.bash_env role playbook] ************************************************************************************************************************************************************************* TASK [Gathering Facts] ******************************************************************************************************************************************************************************************** ok: [servera.lab.example.com] TASK [student.bash_env : put away .bashrc] ************************************************************************************************************************************************************************ changed: [servera.lab.example.com] TASK [student.bash_env : put away .bash_profile] ****************************************************************************************************************************************************************** ok: [servera.lab.example.com] TASK [student.bash_env : put away .vimrc] ************************************************************************************************************************************************************************* changed: [servera.lab.example.com] PLAY RECAP ******************************************************************************************************************************************************************************************************** servera.lab.example.com : ok=4 changed=2 unreachable=0 failed=0 [student@workstation dev-roles]$ md5sum roles/student.bash_env/templates/* f939eb71a81a9da364410b799e817202 roles/student.bash_env/templates/_bash_profile.j2 989764ae6830691e7468599db8d194ba roles/student.bash_env/templates/_bashrc.j2 a7320d70317cd23e0c2083489b532cdf roles/student.bash_env/templates/_vimrc.j2 [student@workstation dev-roles]$ [student@workstation dev-roles]$ [student@workstation dev-roles]$ ssh servera md5sum /etc/skel/{.bash_profile,.bashrc,.vimrc} f939eb71a81a9da364410b799e817202 /etc/skel/.bash_profile 7f6d35286702531c9bef441516334404 /etc/skel/.bashrc a7320d70317cd23e0c2083489b532cdf /etc/skel/.vimrc [student@workstation dev-roles]$ cat roles/student.bash_env/templates/_bashrc.j2 # .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # Uncomment the following line if you don't like systemctl's auto-paging feature: # export SYSTEMD_PAGER= # User specific aliases and functions PS1="{{ default_prompt }}" [student@workstation dev-roles]$ ssh servera tail -n5 /etc/skel/.bashrc # User specific aliases and functions PS1="[student prompt \W]\$ " [student@workstation dev-roles]$ ansible-galaxy init --offline -p roles empty.example - empty.example was created successfully [student@workstation dev-roles]$ tree roles/empty.example/ roles/empty.example/ ├── README.md ├── defaults │ └── main.yml ├── files ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── templates ├── tests │ ├── inventory │ └── test.yml └── vars └── main.yml
Overview
Content Tools
Add Comment