Skip to content

Instantly share code, notes, and snippets.

@drybjed
Created April 16, 2014 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drybjed/10925942 to your computer and use it in GitHub Desktop.
Save drybjed/10925942 to your computer and use it in GitHub Desktop.
---
- hosts: anna
tasks:
- name: Add bob
sudo: yes
user: name=bob
- name: Add some groups
sudo: yes
group: name={{ item }}
with_items:
- bob
- cat
- mouse
- shovel
- name: Add bob to groups bob and cat
sudo: yes
user: name=bob groups=bob,cat
- name: Capture what groups bob has
shell: cat /etc/group | grep bob
register: bob_output
- name: See what groups bob has
debug: var=bob_output
- name: Add bob to groups mouse and shovel
sudo: yes
user: name=bob groups=mouse,shovel append=1
- name: Capture what groups bob has
shell: cat /etc/group | grep bob
register: bob_output
- name: See what groups bob has
debug: var=bob_output
PLAY [anna] *******************************************************************
GATHERING FACTS ***************************************************************
ok: [anna]
TASK: [Add bob] ***************************************************************
changed: [anna]
TASK: [Add some groups] *******************************************************
ok: [anna] => (item=bob)
changed: [anna] => (item=cat)
changed: [anna] => (item=mouse)
changed: [anna] => (item=shovel)
TASK: [Add bob to groups bob and cat] *****************************************
changed: [anna]
TASK: [Capture what groups bob has] *******************************************
changed: [anna]
TASK: [See what groups bob has] ***********************************************
ok: [anna] => {
"bob_output": {
"changed": true,
"cmd": "cat /etc/group | grep bob ",
"delta": "0:00:00.005244",
"end": "2014-04-16 21:48:32.018314",
"invocation": {
"module_args": "cat /etc/group | grep bob",
"module_name": "shell"
},
"rc": 0,
"start": "2014-04-16 21:48:32.013070",
"stderr": "",
"stdout": "bob:x:1004:bob\ncat:x:1005:bob",
"stdout_lines": [
"bob:x:1004:bob",
"cat:x:1005:bob"
]
}
}
TASK: [Add bob to groups mouse and shovel] ************************************
changed: [anna]
TASK: [Capture what groups bob has] *******************************************
changed: [anna]
TASK: [See what groups bob has] ***********************************************
ok: [anna] => {
"bob_output": {
"changed": true,
"cmd": "cat /etc/group | grep bob ",
"delta": "0:00:00.007819",
"end": "2014-04-16 21:48:32.675957",
"invocation": {
"module_args": "cat /etc/group | grep bob",
"module_name": "shell"
},
"rc": 0,
"start": "2014-04-16 21:48:32.668138",
"stderr": "",
"stdout": "bob:x:1004:bob\ncat:x:1005:bob\nmouse:x:1006:bob\nshovel:x:1007:bob",
"stdout_lines": [
"bob:x:1004:bob",
"cat:x:1005:bob",
"mouse:x:1006:bob",
"shovel:x:1007:bob"
]
}
}
PLAY RECAP ********************************************************************
anna : ok=9 changed=6 unreachable=0 failed=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment