Guest User

Ansible Roles are not namespaces

a guest
Aug 3rd, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1.  
  2. ####### first, define two roles, red and blue, each which
  3. ####### define the variable color to be, well, red or blue.
  4.  
  5. ==> roles/red/tasks/main.yml <==
  6. - name: red test
  7. command: echo $color
  8.  
  9. ==> roles/red/vars/main.yml <==
  10. color: red
  11.  
  12. ==> roles/blue/tasks/main.yml <==
  13. - name: blue test
  14. command: echo $color
  15.  
  16. ==> roles/blue/vars/main.yml <==
  17. color: blue
  18.  
  19. ######## define a playbook with the two roles
  20.  
  21. [bowe@catbus ansible]$ head color.yml
  22. - hosts: localhost
  23. roles:
  24. - red
  25. - blue
  26.  
  27. ######## and run it. Both commands echo 'blue' :(.
  28.  
  29. [bowe@catbus ansible]$ ANSIBLE_NOCOWS=1 ansible-playbook -v color.yml
  30.  
  31. PLAY [localhost] **************************************************************
  32.  
  33. GATHERING FACTS ***************************************************************
  34. ok: [localhost]
  35.  
  36. TASK: [red test] **************************************************************
  37. changed: [localhost] => {"changed": true, "cmd": ["echo", "blue"], "delta": "0:00:00.001402", "end": "2013-08-03 15:41:52.397388", "item": "", "rc": 0, "start": "2013-08-03 15:41:52.395986", "stderr": "", "stdout": "blue"}
  38.  
  39. TASK: [blue test] *************************************************************
  40. changed: [localhost] => {"changed": true, "cmd": ["echo", "blue"], "delta": "0:00:00.003406", "end": "2013-08-03 15:41:52.718623", "item": "", "rc": 0, "start": "2013-08-03 15:41:52.715217", "stderr": "", "stdout": "blue"}
  41.  
  42. PLAY RECAP ********************************************************************
  43. localhost : ok=3 changed=2 unreachable=0 failed=0
Advertisement
Add Comment
Please, Sign In to add comment