whether there is an analogue set_facts but keeping the difference between the plays

23 views
Skip to first unread message

Алексей Гаврилов

unread,
Sep 23, 2015, 8:01:13 AM9/23/15
to Ansible Project
whether there is an analogue set_facts but keeping the difference between the plays
register creates a structure, and I would be quite variable.

for what it is to me.
I have in the performance of the play there is a lot of roles with the same addictions and these are carried out according to several times resulting in no effective implementation of the play.

Using variables I want to make the role of roles executed once for all the play.

example

---
- hosts: mail_srv
  remote_user
: an
  sudo
: yes

  roles
:
   
- le9i0nx.base
   
- le9i0nx.zram
   
- le9i0nx.hp.dl320
   
- debops.users
   
- debops.console
   
- debops.ntp
   
- debops.sshd
   
- debops.secret
   
- debops.mysql
   
- le9i0nx.ssl_key
   
- le9i0nx.postfixadmin
   
- le9i0nx.roundcube
   
- le9i0nx.mailweb
   
- le9i0nx.dovecot

ansible/roles/debops.mysql/meta/main.yml
---
dependencies
:
 
- role: debops.secret
 
- role: debops.ferm
    ferm_input_list
:
     
- type: 'dport_accept'
        dport
: [ 'mysql' ]
        saddr
: '{{ mysql_mysqld_allow }}'
        weight
: '50'
        filename
: 'mysql_dependency_accept'
 
- role: debops.tcpwrappers
    tcpwrappers_allow
:
     
- daemon: 'mysqld'
        client
: '{{ mysql_mysqld_allow }}'
        weight
: '50'
        filename
: 'mysql_dependency_allow'
        comment
: 'Allow remote connections to MySQL server'

ansible/roles/le9i0nx.dovecot/meta/main.yml
---
dependencies
:
 
- role: debops.secret
 
- role: debops.rsyslog
    rsyslog_pools
: [ '{{ rsyslog_pool_dovecot }}' ]
    rsyslog_pool_dovecot
:
        enabled
: True
        name
: '01-dovecot'
        options
: |
            $template
DynFileErr,"/var/log/%HOSTNAME%/%programname%/%$YEAR%.%$MONTH%.%$DAY%.err"
           
if $programname == "dovecot" and $syslogfacility-text == "mail" and $syslogseverity-text == "err" then ?DynFileErr
           
& stop
 
            $template
DynFile,"/var/log/%HOSTNAME%/%programname%/%$YEAR%.%$MONTH%.%$DAY%.log"
           
if $programname == "dovecot" then ?DynFile
           
& stop

 
- role: debops.ferm
    ferm_input_list
:
     
- type: 'dport_accept'
        dport
: [ 'pop3', 'pop3s','imap2','imaps','sieve' ]
        accept_any
: True
        filename
: 'dovecot_dependency_accept'
        weight
: '20'

Алексей Гаврилов

unread,
Sep 24, 2015, 6:32:17 AM9/24/15
to Ansible Project
I solved his problem like this

---
- hosts: mail_test
  remote_user
: ansicon
  sudo
: yes


  roles
:
   
- le9i0nx.dspam
   
- le9i0nx.dspam

ansible/roles/le9i0nx.dspam/meta/main.yml
---
- name: init dspam
  include
: init.yml
 
when: role_dspam_register_init is not defined
   
- name: init dspam register
  command
: /bin/true
 
register: role_dspam_register_init
 
when: role_dspam_register_init is not defined
  changed_when
: False

Reply all
Reply to author
Forward
0 new messages