geerlingguy / geerlingguy/ansible-for-devops

Page 39 - Chapter 3 - Enable firewalld on db

Open
#433 6 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
9.9k
Forks
3.8k
PR merge metrics
No merged PRs in 30d

Description

Firstly, thank you for such a well written book written for what seems to be people exactly like me!

When I run the commands to enable and configure firewalld, everything seems to run. But when I log into the vagrant db to validate, I see no firewalld rules or iptables rules...

I'm more of iptables guy than a firewalld guy, so maybe my validation is being done improperly. Can you give me a quick sanity check?

Vagrantfile:

```
~/AnsibleClass2$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# General Vagrant VM configuration.
config.vm.box = "geerlingguy/centos8"
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider :virtualbox do |v|
v.memory = 512
v.linked_clone = true
end

# Application server 1.
config.vm.define "app1" do |app|
app.vm.hostname = "orc-app1.test"
app.vm.network :private_network, ip: "192.168.60.4"
end

# Application server 2.
config.vm.define "app2" do |app|
app.vm.hostname = "orc-app2.test"
app.vm.network :private_network, ip: "192.168.60.5"
end

# Database server.
config.vm.define "db" do |db|
db.vm.hostname = "orc-db.test"
db.vm.network :private_network, ip: "192.168.60.6"
end
end
```

Ansible Commands:

```
ansible db -b -m yum -a "name=firewalld state=present"
ansible db -b -m service -a "name=firewalld state=started enabled=yes"
ansible db -b -m firewalld -a "zone=database state=present permanent=yes"
ansible db -b -m firewalld -a "source=192.168.60.0/24 zone=database state=enabled permanent=yes"
ansible db -b -m firewalld -a "port=3306/tcp zone=database state=enabled permanent=yes"
```

DB Validation:

```
meleschi@vm-ansible-02:~/AnsibleClass2$ ansible db -b -a "iptables -L"
192.168.60.6 | CHANGED | rc=0 >>
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

meleschi@vm-ansible-02:~/AnsibleClass2$ ansible db -b -a "firewall-cmd --list-all"
192.168.60.6 | CHANGED | rc=0 >>
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3 enp0s8
sources:
services: cockpit dhcpv6-client ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.