diff --git a/resources/ansible_local/actions/run.yaml b/resources/ansible_local/actions/run.yaml index ce81d261..7351a738 100644 --- a/resources/ansible_local/actions/run.yaml +++ b/resources/ansible_local/actions/run.yaml @@ -1,4 +1,9 @@ -- hosts: '*' +- hosts: localhost sudo: yes + vars: + var1: 'playbook' roles: - - { role: "test_role" } \ No newline at end of file + - { role: "test_role" } + tasks: + - debug: msg="VAR1 value is {{var1}}" + - fail: msg='just test failure' \ No newline at end of file diff --git a/resources/ansible_local/meta.yaml b/resources/ansible_local/meta.yaml index 77a47f18..cddbb391 100644 --- a/resources/ansible_local/meta.yaml +++ b/resources/ansible_local/meta.yaml @@ -4,7 +4,7 @@ version: 0.0.1 input: var1: type: str! - value: some_value + value: meta uuid: type: str! value: 'aa1das1231' diff --git a/resources/ansible_remote/actions/run.yaml b/resources/ansible_remote/actions/run.yaml index 5206f498..7482f7f8 100644 --- a/resources/ansible_remote/actions/run.yaml +++ b/resources/ansible_remote/actions/run.yaml @@ -1,4 +1,6 @@ - hosts: '*' sudo: yes + vars: + default1: playbook tasks: - - debug: "my message" \ No newline at end of file + - debug: msg="my message {{default1}}" \ No newline at end of file diff --git a/resources/ansible_remote/meta.yaml b/resources/ansible_remote/meta.yaml index 626215f5..90026220 100644 --- a/resources/ansible_remote/meta.yaml +++ b/resources/ansible_remote/meta.yaml @@ -11,3 +11,6 @@ input: ssh_key: type: str! value: + default1: + type: str! + value: meta diff --git a/solar/solar/core/handlers/ansible_playbook.py b/solar/solar/core/handlers/ansible_playbook.py index f36faea6..06a5dd7b 100644 --- a/solar/solar/core/handlers/ansible_playbook.py +++ b/solar/solar/core/handlers/ansible_playbook.py @@ -8,6 +8,7 @@ from ansible import callbacks import ansible.constants as C from solar.core.handlers import base +from solar import errors class AnsiblePlaybook(base.BaseHandler): @@ -24,16 +25,16 @@ class AnsiblePlaybook(base.BaseHandler): remote_user = variables.get('ssh_user') or C.DEFAULT_REMOTE_USER private_key_file = variables.get('ssh_key') or C.DEFAULT_PRIVATE_KEY_FILE if variables.get('ip'): - host_list = [variables['ip']] + host = variables['ip'] transport = C.DEFAULT_TRANSPORT else: - host_list = ['localhost'] + host = 'localhost' transport = 'local' play = PlayBook( playbook=action_file, remote_user=remote_user, - host_list = host_list, + host_list = [host], private_key_file=private_key_file, extra_vars=variables, callbacks=playbook_cb, @@ -41,4 +42,10 @@ class AnsiblePlaybook(base.BaseHandler): stats=stats, transport=transport) - return play.run() + play.run() + summary = stats.summarize(host) + + if summary.get('unreachable') or summary.get('failures'): + raise errors.SolarError( + 'Ansible playbook %s failed with next summary %s', + action_file, summary)