Commit 292ac4aa by Michael DeHaan

Make it such that the 'name' element of each playbook line is optional.

parent 44d4dede
...@@ -15,11 +15,9 @@ ...@@ -15,11 +15,9 @@
- name: test basic user account creation - name: test basic user account creation
action: user name=tset comment=TsetUser gid=100 shell=/sbin/nologin createhome=no action: user name=tset comment=TsetUser gid=100 shell=/sbin/nologin createhome=no
- name: test user account modification # the following is just a simple example of how you don't have to include
action: user name=tset comment=NyetUser # the 'name' element for each task
- name: test user account password change - action: user name=tset comment=NyetUser
action: user name=tset password=$password - action: user name=tset password=$password
- action: user name=tset state=absent
- name: test user account modification
action: user name=tset state=absent
...@@ -336,8 +336,12 @@ class PlayBook(object): ...@@ -336,8 +336,12 @@ class PlayBook(object):
host_list = self._prune_failed_hosts(host_list) host_list = self._prune_failed_hosts(host_list)
# load the module name and parameters from the task entry # load the module name and parameters from the task entry
name = task['name'] # FIXME: error if not set name = task.get('name', None)
action = task['action'] # FIXME: error if not set action = task.get('action', None)
if action is None:
raise errors.AnsibleError("action is required for each item in tasks")
if name is None:
name = action
only_if = task.get('only_if', 'True') only_if = task.get('only_if', 'True')
async_seconds = int(task.get('async', 0)) # not async by default async_seconds = int(task.get('async', 0)) # not async by default
async_poll_interval = int(task.get('poll', 10)) # default poll = 10 seconds async_poll_interval = int(task.get('poll', 10)) # default poll = 10 seconds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment