optimize playbook

34 views
Skip to first unread message

Alexey Lesovsky

unread,
Apr 30, 2014, 9:56:01 AM4/30/14
to ansible...@googlegroups.com
Hi all!
I write role for Ansible Galaxy, and have a little problem. I have 2 host groups and need execute different tasks for this groups. At this moment I doing it with the following configuration, this is the root playbook.yml
- hosts: all
  sudo
: yes
  sudo_user
: root
  vars_files
:
   
- 'defaults/main.yml'     # main configuration
   
- 'defaults/repo.yml'     # repositories which must not be changed in normal case
  tasks
:
 
- include: 'tasks/install.yml'

- hosts: streaming-master
  sudo
: yes
  sudo_user
: root
  vars_files
:
   
- 'defaults/main.yml'
   
- 'defaults/repo.yml'
  tasks
:
 
- include: 'tasks/configure-master.yml'
 
- include: 'tasks/users.yml'
 
- include: 'tasks/databases.yml'

- hosts: streaming-slaves
  sudo
: yes
  sudo_user
: root
  vars_files
:
   
- 'defaults/main.yml'
   
- 'defaults/repo.yml'
  tasks
:
 
- include: 'tasks/configure-slaves.yml'

Аs you can see, there are many duplicate information (sudo/sudo_user/vars_files), how to avoid it?

Petr Sukharev

unread,
Apr 30, 2014, 12:56:31 PM4/30/14
to ansible...@googlegroups.com
Put in in ansible.cfg file, with contain default values for ansible. Like remote user or sudo. And many others :)
Reply all
Reply to author
Forward
0 new messages