Hello. Now I do sime things from roles/host_generic/tasks/main.yaml:
- include: ../../includes_common/pkg_from_repo.yaml
vars:
name: 'bash'
- include: ../../includes_common/pkg_from_repo.yaml
vars:
name: 'bash-completion'
- include: ../../includes_common/pkg_from_repo.yaml
vars:
name: "{{generic_vim_pkg_name}}"
- include: ../../includes_common/pkg_from_repo.yaml
vars:
name: 'screen'
- include: ../../includes_common/pkg_from_repo.yaml
vars:
name: 'logrotate'
- include: ../../includes_common/pkg_from_repo.yaml
vars:
name: 'sudo'
- include: ../../includes_common/pkg_from_repo.yaml
vars:
name: 'wget'
- include: ../../includes_common/pkg_from_repo.yaml
vars:
name: 'rsync'
- include: ../../includes_common/pkg_from_repo.yaml
vars:
name: 'munin-node'
I guess it's a long way. Is it possible to reuse some code from roles
shorter? Using role from other role will be perfect solution, but I unable
to found way how.
roles/includes_common/pkg_from_repo.yaml is installer for all possible
operation systems is I replace includes in previous file to modules
command, this file will bigger at 3-4 times.
---
- name: install RedHat package
yum: name="{{name}}" state=present
when: ansible_os_family == 'RedHat'
- name: install RedHat package
apt: name="{{name}}" state=present
when: ansible_os_family == 'Debian'
- name: install RedHat package
openbsd_pkg: name="{{name}}" state=present
when: ansible_system == 'OpenBSD'
- name: install FreeBSD package
pkgng: name="{{name}}" state=present
when: ansible_system == 'FreeBSD'
Also, it is incorrect decision to move pkg_from_repo.yaml to another
directory like roles/host_generic/tasks, because from other roles it will
be called as "include: ../../host_genetic/tasks/pkg_from_files.yaml" - much
more text in call.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ab61eb2a-8a0e-4652-8d9a-0bf61cb73c9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.