Reputation: 59
I am looking to execute a remote shell script and get the output. The confliction occurs in the tasks/build.yml file:
- name: Execute setup.sh in Git repository
command: chdir=/opt/{{ repo_name }} {{ item }}
with_items:
- ./setup.sh
register: command_output
debug:
var: command_output.stdout_lines
Here is main.yml:
---
- name: Clone and Build Project
hosts: all
gather_facts: true
become: true
vars_files:
- vars/gitlab.yml
tasks:
- include: tasks/clone.yml
- include: tasks/dependencies.yml
- include: tasks/build.yml
The playbook executes successfully w/o debugging information. After I try to output debug info it fails with that error.
Upvotes: 1
Views: 1226
Reputation: 18391
You are mixing two tasks, you need to use register
for 1st task and debug
it in 2nd task. Also notice that, you are using with_items
this means, you will have to use debug
over <registername>.results[<item>].stdout_lines
- name: Execute setup.sh in Git repository
command: chdir=/opt/{{ repo_name }} {{ item }}
with_items:
- ./setup.sh
register: command_output
- debug:
var: command_output.results[0].stdout_lines
Upvotes: 1