R
R
romankulish52018-11-26 17:37:16
YAML
romankulish5, 2018-11-26 17:37:16

How to make ansible enums in playbook?

Hello.
How to make enumerations in ansible: attributes?
For example:
I want to open an RDP port on Windows for multiple IPs
- name: Firewall rule to allow RDP on TCP port 3389
win_firewall_rule:
name: Remote Desktop
localport: 3389
action: allow
direction: in
protocol: tcp
profiles: private
remoteip: '"1.1 .1.1.", "2.2.2.2'
state: present
enabled: yes
Or open multiple ports at once:
- name: Firewall rule to allow RDP on TCP port 3389
win_firewall_rule:
name: Remote Desktop
localport: ['3389', '21' ]
action: allow direction
: in protocol :
tcp profiles
: private
state: present
enabled: yes 23 "' Help, please. How to do it right?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Softer, 2018-11-26
@romankulish5

https://docs.ansible.com/ansible/2.5/user_guide/pl...

S
Sanes, 2018-11-26
@Sanes

An example from my playbook. Might fit.

- name: 'Default configs Apache2 & PHP'
      template: 'src={{item.src}} dest={{item.dest}} backup=yes'
      with_items:
       - { src: 'templates/apache2/000-default.conf.j2', dest: '/etc/apache2/sites-available/000-default.conf' }
       - { src: 'templates/php/7.0/cli/php.ini.j2', dest: '/etc/php/7.0/cli/php.ini' }
       - { src: 'templates/php/7.0/apache2/php.ini.j2', dest: '/etc/php/7.0/apache2/php.ini' }
      notify:
       - 'apache2 reload'

P
Puma Thailand, 2018-11-27
@opium

Do it with with items

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question