Passing variables to ansible roles

I got it working by using this playbook:

---
- hosts: testdroplets
  roles:
    - update
    - bootstrap_server
    - role: create_new_user
      username: username
    - role: vimserver
      username: username

Docs: http://docs.ansible.com/ansible/playbooks_roles.html#roles


Here is another option, with a directory structure like

.
├── README.md
├── ansible.cfg
├── play.yml
└── roles
    ├── bootstrap_server
    │   └── tasks
    │       └── main.yml
    ├── create_new_user
    │   ├── defaults
    │   │   └── main.yml
    │   └── tasks
    │       └── main.yml
    ├── update
    │   └── tasks
    │       └── main.yml
    └── vimserver
        ├── defaults
        │   └── main.yml
        ├── files
        │   └── vimrc_server
        └── tasks
            └── main.yml

Where I am creating a defaults/main.yml file inside the roles where I need the usage of {{username}}

If someone is interested in the code: https://github.com/tasdikrahman/ansible-bootstrap-server

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)