Ask Your Question
0

crayfishx/firewalld add multiple ports

asked 2016-08-23 10:31:57 -0500

alexseys gravatar image

updated 2016-08-23 10:33:24 -0500

Downloaded crayfishx/firewalld but can't seem to find a way to add multiple ports

Created ...hieradata/hostname.yaml, but only last port is added, client is cents 7.

firewalld::ports:
  public:
    ensure: present
    port: 8080
    protocol: 'tcp'

firewalld::ports:
  public:
    ensure: present
    port: 5667
    protocol: 'tcp'

Thank you,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-08-26 04:00:40 -0500

lupin gravatar image

updated 2016-08-26 22:54:43 -0500

You can create a similar structure on your hiera file.

firewalld::ports:
  8080_tcp:
    zone: public
    port: 8080
    protocol: tcp
  5667_tcp:
    zone: public
    port: 5667
    protocol: tcp

and then on your manifest use create_resources function.

class usecase {
  $ports = hiera('firewalld::ports')
  create_resources(firewalld_port, $ports, { ensure => 'present' })
}

Sample result below. You might need to notify a service reload on your case.

[root@ha manifests]# puppet apply ../tests/init.pp 
Notice: Compiled catalog for ha.home in environment production in 0.73 seconds
Notice: /Stage[main]/Usecase/Firewalld_port[8080_tcp]/ensure: created
Notice: /Stage[main]/Usecase/Firewalld_port[5667_tcp]/ensure: created
Notice: Finished catalog run in 0.95 seconds
[root@ha manifests]# firewall-cmd --reload; firewall-cmd --list-all
success
public (default, active)
  interfaces: enp0s3 enp0s8
  sources: 
  services: dhcpv6-client ssh
  ports: 80/tcp 3260/tcp 8080/tcp 5667/tcp
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules:
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-23 10:31:57 -0500

Seen: 75 times

Last updated: Aug 26 '16