Basic Info required please regarding the sequence that tasks inside a role are executed in

13 views
Skip to first unread message

Michael Byrne

unread,
Dec 7, 2016, 9:31:10 AM12/7/16
to Ansible Project
Hi,

I'm new to Ansible so apologies for the the basic question.
 I have a role called "manage_prod_logs"
I created the directory structure automatically using the command   -->  "ansible-galaxy init manage_prod_logs"

Within the directory structure, I have a file   ..........\tasks\mail.yml
It looks as follows:
________________________________________________________________________________________________________________________________________
---
- name: Copy_File
  copy: src=/bt/brandtone/task-automation/scripts/log_file_archiver.bash dest=/bt/scripts/log_file_archiver.bash owner=ansible force=yes group=brandtone mode=4755

- name: Run_Script
  command: "/bin/bash /bt/scripts/log_file_archiver.bash"
  become: true
  args:
   chdir: /bt/scripts
_________________________________________________________________________________________________________________________________________

The playbook is actually working properly at the moment for the remote host.
My question is, will the task "Copy_File" above always execute before the task "Run_Script" by virtue of their positioning within the task list
or do I need to do something else to ensure they always execute in sequence.

Many thanks in advance,

Rgds,

Michael

Kai Stian Olstad

unread,
Dec 8, 2016, 2:09:07 AM12/8/16
to ansible...@googlegroups.com
On 05.12.2016 11:19, Michael Byrne wrote:
> Hi,
>
> I'm new to Ansible so apologies for the the basic question.

I would recommend you read this page, it give answers to many basic
question like this
https://docs.ansible.com/ansible/playbooks_intro.html


> I have a role called "*manage_prod_logs*"
> It looks as follows:
> ________________________________________________________________________________________________________________________________________
> ---
> - name: *Copy_File*
> copy:
> src=skins/larry/bt/brandtone/task-automation/scripts/log_file_archiver.bash
> dest=/bt/scripts/log_file_archiver.bash owner=ansible force=yes
> group=brandtone mode=4755
>
> - name: *Run_Script*
> command: "/bin/bash /bt/scripts/log_file_archiver.bash"
> become: true
> args:
> chdir: /bt/scripts
> _________________________________________________________________________________________________________________________________________
>
> The playbook is actually working properly at the moment for the remote
> host.
> My question is, will the task "*Copy_File*" above always execute before
> the
> task "*Run_Script*" by virtue of their positioning within the task list
> or do I need to do something else to ensure they always execute in
> sequence.

Yes, Ansible always run tasks in the listed order, starting from top to
bottom in the file.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages