Trending February 2024 # How Does Ansible Firewalld Works With Examples # Suggested March 2024 # Top 7 Popular

You are reading the article How Does Ansible Firewalld Works With Examples updated in February 2024 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 How Does Ansible Firewalld Works With Examples

Introduction to Ansible Firewalld

In Ansible, we have many modules that provide us the ability to perform operational work on remote hosts. Especially, operations which are to be done on Linux remote hosts. One such module is named firewalld, which is used to manage firewall rules of Linux systems. In this topic, we are going to learn about Ansible Firewalld.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

As we know that Linux systems can have a firewalld daemon that is used to allow/block access to/from services, networks, and ports by updating running or permanent firewall rules on the machine via firewall-cmd utility. The same is managed by Ansible using the firewalld module.

Explaining the Ansible Firewalld

Ansible firewalld is the module that is used to update firewall rules on remote hosts. The remote hosts are the Linux machines here. Ports can be TCP or UDP, which can be enabled or disabled. Similarly, services can be allowed or blocked.

We should note below points while working with Ansible firewalld module: –

As per the latest Ansible firewalld module, the firewalld version on the hosts, where firewall rules will be modified, should have equal to or greater than 2.11.

This module is not tested in Debian based

Requires python2 bindings of firewalld. Where python2 bindings are not available, python3 bindings can be used but we must set ansible_python_interpreter to python3 interpreter path and install python3

There is a known limitation in Ansible firewalld due to which zone transactions must explicitly be permanent. This also means that when we add a zone and want to perform immediate actions on it, we need to reload the firewalld service. But take care while doing that because reloading firewalld will undo all non-permanent actions performed

This module is not guaranteed to have backward

Along with the above points, we should also know below terminologies which are heavily used in firewalld.

Zone: Zone is a logical network location which can be arbitrary but can be defined in terms of the network from which traffic will originate, or a location to which your local network interface is connected.

Services: Services are the series of ports and protocol combination which works as the socket, that our host is listening on, which then can be placed in one or more

Ports: These are the logical constructs which are representing a service endpoint

How Does Ansible Firewalld Works?

Because handling rules in an ad hoc way will end up in a mess and we need to spend hours and network support to identify the problematic parts in our firewall rules.

icmp_block: The icmp block we like to remove or add from or to a zone in firewall rules

immediate: if the permanent parameter is used, should this be applied

interface: The interface we like to remove or add to or from a zone in firewall rules

permanent: Should the configuration be in permanent rule, which persists across reboots or in running configuration temporarily. When this is “no”, then by default immediate is “yes”.

Acceptable values are either “yes” or “no”.

1. port: Name or port or port range to remove or add to or from firewalld. When giving ranges, it must be in the form of PORT/PROTOCOL or PORT-PORT/PROTOCOL for port

2. rich_rule: rich rule to add or remove to or from

3. service: The service which needs to be added or removed to or from firewalld. The service must be listed in the output of the “firewall-cmd –get-services” command on remote

4. source: The source network you would like to be removed or added to or from in firewalld rules.

5. state: Enable or disable a setting. Below are acceptable values from which present and absent

are used in case of zone level operation.





6. timeout: The time for which rule should be in effect when set as non-permanent

7. zone: The firewall zone to be added or removed. The public is default zone from upstream but this can be configured. Some out of box defaults are block, DMZ, external, internal, trusted, work. This list can be extended based on a per system

Example of Ansible Firewalld

Now by using examples, we will try to learn about Ansible firewalld, which you might have to use in day to day operations. We will take some examples, but before going there, we first understand our lab, we used for testing purpose.

Here we have an Ansible control server named ansible-controller and one remote host named host- remote. We will create playbooks and run Ansible commands on the ansible-controller node and see the results on the remote host.

Also, on the remote host, below is the current status of firewalld.

firewall-cmd --state

firewall-cmd --get-services

firewall-cmd --get-zone

firewall-cmd --list-all

We will use a playbook with below content: –

When we execute it like below we get below output: –

ansible-playbook ansible_firewalld_enable_service.yaml

firewall-cmd --list-all

In this example, we will see how to enable a port in remote host, for this we have a playbook like below content: –

port: 443/tcp state: enabled

ansible-playbook ansible_firewalld_disable_port.yaml

Now checking on the remote host, we will see this port is listed in the output of –list-all now like below, but it was not there previously: –

firewall-cmd --list-all

In this example, we will enable an ip range for a zone, for this we have a playbook like below, Note here that as we are doing a zone related transaction so for this to work we need to make it permanent and also immediately reload firewalld on the remote host, like below: –

name: we have to reload firewalld else zone transactions will not be realised command: firewall-cmd –reload

After executing this playbook we get the below output: –

ansible-playbook ansible_firewalld_enable_source_network.yaml

On the remote host, we can see that the mentioned network is listed on the concerned zone’s allowed list

firewall-cmd --zone=internal --list-all


As we have seen that Ansible firewalld is a very powerful module which can be very useful if you have supported network and your remote hosts are supportable in all ways. But points to note that it is not an easy task to have a track of all the firewall rule, especially when we have permanent and non- permanent rules. So that preparation is needed before-hand.

Recommended Articles

This is a guide to Ansible Firewalld. Here we discuss the introduction to Ansible Firewalld along with the working, detailed explanation and respective examples. You may also look at the following articles to learn more –

You're reading How Does Ansible Firewalld Works With Examples

How Linux Zcat Command Works With Programming Examples

Introduction to Linux Zcat

In Linux Zcat, Linux ecosystem, we are able to compress the files with the help of gzip or gunzip. But when we need to check the compress file content without uncompressing the compressed files then we are using the zcat command.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Note: The zcat utility is only working with the gzip or gunzip compress files. If it will work with the tar compression technique, it will not work. It will provide the garbage value. The Zcat command utility was written by Miloslav Trmac.


Syntax of Zcat command:

zcat [ option ] [ name ]

zcat: We can use the zcat keyword in the syntax or command. It will take the two-argument as an option and file name. Provide the end result to display the compress file content without uncompressing the file.

option: We can provide the different flags as options that are compatible with the zcat command example “-fhLV”.

How does Linux Zcat Command work?

Basically, the zcat is a command-line utility. It is used to display the compressed file content without uncompressing the compressed file. It will swell the compressed file into standard output and allowing to end-user to look at the contents available in it. A few more updates, the zcat is compatible to run the gunzip –c command.

The zcat command is majorly working with two components i.e. option and the compressed file name. When any end-user or client will trigger the zcat command? The zcat command will accept the input as an option and compressed file as standard input and display the compress file content as standard output.

Examples to Implement Linux Zcat Command

Below are examples mentioned:

1. Zcat Command

It is a very simple and common way to use the zcat command in a Linux environment. It will print the compress file content which is provided to the zcat command.


zcat data.txt.gz


Explanation: We are creating a few sample files in the data directory. As per screenshot 1 (a), we have created the chúng tôi file and compress it with the help of gzip. With the help of the zcat command, we are able to read the compressed file content (refer screenshot 1 (b)). In the same file contented, we are not able to read with normal cat command (refer screenshot 1 (c)).

2. Zcat Command: Multiple Compressed File View

In zcat command, we are having the functionality to view the multiple compressed files at the same time in the same command.


zcat chúng tôi data1.txt.gz


Explanation: As per the above zcat command, we are able to read the number of compress file at the same time. From the data directory, we are reading the two compress files i.e. chúng tôi data1.txt.gz at the same time.

3. Zcat Command: Force File View

In the zcat command, we are having the functionality to display the file content whether the file is compressed or not. To print the file contented forcefully, we need to use the “-f” option with the zcat command.

zcat -f data.txt.gz


Explanation: As per the below screenshot, the zcat file is compatible with gzip files. But if we need to read the content of the normal file, it will not possible. Hence we need to use the “-f” option to read the file forcefully with the zcat command.

4. Zcat Command: With More Command

When do we need to display the huge compress file data? It would be more difficult to display the data in a single window. We can use the more command to view the zcat data.

Note: We can use the more command functionality with the zcat command.



Explanation: If we need to view the huge amount of log data, it would be more difficult to view or print in a single screen. We can use the more command functionality to read the huge amount of compressed log files.

Note: we are using pipe functionality to read the zcat data in more command.

5. Zcat Command: With Less Command

In the zcat command, we are having the functionality to display the huge amount of data with less command utility.

Note: We can use the more command functionality with the zcat command.



Explanation: As per the more command, we can read the huge compressed file. Similarly, we can use the less command functionality to read the huge amount of compressed log files.

Note: we are using pipe functionality to read the zcat data in less command.

6. Zcat command: Print Compression Information

With the help of the zcat command, we are able to get the compression information of the file. To print the compression information, we need to use the “-l” option with the zcat command.


zcat -l log.txt.gz


Explanation: As per the above command, we are able to find the compression status of the compressed file. We are using one of the log files i.e. chúng tôi The compression information will display the compressed, uncompressed, ratio information with the compressed file name.

7. Zcat Command – suppress Warning

Some times while printing any compress data, the lots of warning come. To avoid this condition, we need to use the “-q” option with the zcat command.


zcat -q data.txt.gz


Explanation: When we are reading the compress file content, sometimes the number of warning comes due to different issues. As per the below screenshot, we can avoid the warring while reading the compressed file contented. We can use the “-q” option with the zcat command to avoid the warning.


We have seen the uncut concept of “Linux Zcat Command” with the proper example, explanation and command with different outputs. The zcat command is compatible with the gunzip –c command. It will really helpful to print the compress file content without uncompressing the actual file.

Recommended Articles

We hope that this EDUCBA information on “Linux Zcat” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

How When Statement Works In Kotlin With Examples?

Introduction to Kotlin when

Web development, programming languages, Software testing & others


In kotlin language, it has many default keywords, variables, and functions to implement the application. One of the default keywords can be used in both expression and non-expression scenarios.

val variablename; when(variablename) { —some coding logics it depends upon the requirement— } }

The above codes are the basic syntax for utilizing the when keyword on the kotlin codes. We want to write the expression based on the function’s requirement on the child function, or the inheritance concept will be implemented on the application.

Working of when statement in Kotlin

Generally, “when” is one of the keywords, and it is used in both expression and non-expression; it also checks and combined with the valid conditional statements depending on the calculation based on the user requirements, in kotlin, when it is constructed, and it can be thought of as the replacement for the switch case statement, which is similar to the other languages when the keyword is used as the expression and validating the condition like matching the values for overall expression. If condition statement, the values of the individual branches are always ignored, each branch can be of the block, and its value is the last expression of the block values.

Else loop is evaluated if none of the other branches and the condition is satisfied with the boolean condition statements; else, a loop is mandatory unless the compiler can prove that all possible cases are covered with the loop conditions. The scope of the variable is introduced with the keyword for when the subject is restricted to the body of this keyword for when expression. We can check and validate the condition using a particular type in both compile and runtime in the kotlin operators. With the help of conditional statements, the loop will use the control, and it executes the other conditions based on their needs.

Examples of Kotlin when

Below are the examples of Kotlin when:

Example #1


package one; println("Welcome To My Domain it’s a first example regarding the When keyword using the kotlin program logics") var first = 7 var second = when(first) { } println("$second") var third = when(second) { } println("Thank you users have a nice day please find your outputs $first") }


We used the above example when keywords in basic formats like int, string, string, and string formats. We can print the statements on the user console screen.

Example #2


package one; println("Welcome To My Domain it’s a second example regarding the When keyword using the kotlin program logics") var first = 'A' when(first){ } println("Thank you users have a nice day kindly try again please keep and stay with our application $first") var yrsage = 16 when(yrsage) { val numlast = 100 - yrsage println("Your marraige age is in $numlast years") } } }


Example #3


package one; enum class Third(val exampl: Boolean = false){ January(true), February, March, April(true), May, June, July(true), August, September, October, November, December(true); companion object{ fun demo(obj: Third): Boolean { } } } fun demos(th: Third) { when(th) { } } fun main(){ println("Welcome To My Domain its a third example regarding the When keyword using the kotlin program logics") for(eg in Third.values()) { println("${eg.ordinal} = ${} and is months in ${eg.exampl}") } val demo1 = Third.April; println("Thank you users your current month is ${Third.demo(demo1)}") }


In the final example, we used to calculate the current month status by using the boolean condition. We used the when keyword to print the enum class value on the function.


In the conclusion part, kotlin when is one of the conditional statements like if, else, etc. The when keyword supports non -conditional expressions also instead of the switch case statement, these statements will execute the user inputs on each step. It supports all types of user browsers, so it’s compatible when keyword satisfied with some range intervals, which depends upon the requirement.

Recommended Articles

This is a guide to Kotlin when. Here we discuss the introduction, syntax, and working of when statement in Kotlin along with the examples and outputs. You may also have a look at the following articles to learn more –

How Does Risk Parity Work With Examples?

What is Risk Parity?

Start Your Free Investment Banking Course

Download Corporate Valuation, Investment Banking, Accounting, CFA Calculator & others

Explanation How Does Risk Parity Work?

The risk parity strategy uses leverage to diversify and reduce the equity risk of an investment portfolio while maintaining the returns at the long-term target level. Using leverage allows investment in lower-risk assets such that the overall portfolio’s return is similar to equity-like returns. The portfolio leverage (by borrowing) with a higher allocation to lower-risk assets delivers a higher return than a direct investment in higher-risk assets with a similar risk level. So, higher allocation goes into bonds compared to equities, as stocks are typically riskier than bonds. In this way, it ensures that risk contribution from both asset classes is equal. Next, it is essential to ensure that the cost of borrowing is sufficiently low such that the net return of the leveraged portfolio (= portfolio return -borrowing cost) exceeds the expected return of the traditional allocation. It is a compelling strategy for investors with easy access to borrowed funds.

Examples of Risk Parity

The following are examples of some of the best risk parity funds available in the world:

AQR Risk Parity II HV Fund (QRHIX): The fund was started on 5th November 2012, and as of 13th November 2023, its total assets under management (AuM) stand at ~$23 million. The fund allocation is such that ~37% of the AuM is invested in equities, ~26% in nominal interest rate bonds, and ~37% in inflation-linked bonds, which results in an equity and bond mix of 1:1.7. During the last three years/ 5 years/ since inception, the fund has generated return of 4.79%/ 6.70%/ 4.34%, which indicates that its performance has been slightly fluctuating with realized volatility of 12.5% since inception. The fund’s management fee and adjusted expenses ratio are 0.80% and 1.03%, respectively.

Horizons Resolve Adaptive Asset Allocation ETF (HRAA): The fund was started on 21st July 2024 as Horizons Global Risk Parity ETF (HRA), Canada’s first Global risk parity fund. On 30th July 2023, the fund was reorganized into Horizons Resolve Adaptive Asset Allocation ETF, and as of 20th September 2023, its total assets under management (AuM) stand at ~$70 million. The fund allocation is such that ~6% of the AuM is invested in equities and ~53% in bonds. Before reorganization, the fund generated returns of 1.35% in the last three years with a volatility of 5.75%. The fund’s management fee is 0.85% plus 15% of the amount by which the fund outperforms the high water mark.

Source: Horizon ETFs, Yahoo Finance

Who Invented Risk Parity?

It was Bridgewater Associates that first launched a risk parity fund by the name All Weather asset allocation strategy in the year 1996. Although the risk parity fund was introduced to the market by Bridgewater Associates, the term was not coined until 2005, when Edward Qian of PanAgora Asset Management first used this term in his authored white paper. In 2008, Andrew Zaytsevof Alan Biller and Associates named Risk Parity one of his investment categories. Soon, the entire asset management industry adopted the term.


Typically, any risky asset generates higher returns than plain cash. So, it makes sense to borrow and purchase risky assets (a.k.a. financial leverage) to earn higher portfolio returns. This strategy results in negative allocation to cash while the allocation to risky assets (mix of bonds and stocks) exceeds 100%. In the above chart, it can be seen that as compared to the traditional portfolio allocation of 60% to equities and 40% to bonds in the 3-asset risk parity portfolio, the portfolio allocation to equities has been halved and that of bonds has been increased three-fold resulting in negative allocation to cash (indicating borrowed fund). In this way, the portfolio risk contribution of equities is brought down while increasing that of bonds to ensure equal risk contribution of both the asset classes (considering zero risk for cash).

Criticisms Conclusion

So, it can be seen that the risk parity approach is an essential portfolio management strategy wherein the capital allocation is done in such a way that the risk contribution of each asset class is equal. The risk parity approach is believed to result in a higher Sharpe ratio, i.e., higher risk-adjusted return.

Recommended Articles

This is a guide to Risk Parity. Here we also discuss the introduction and how does it work? Along with examples. You may also have a look at the following articles to learn more –

How Does Powershell Wget Work With Examples?

Introduction to PowerShell wget

The PowerShell Wget, which is an alias for the Invoke-WebRequest in PowerShell, is a non-interactive utility that sends the request to the HTTP or HTTPS web page or the web services and parses the response and returns the collection of the links, images, and HTML elements and it also helps to download the files from the webpage, post or delete or modify the data on the website with the forms, checks the status of the websites, etc.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others


[-UseBasicParsing] [-AllowUnencryptedAuthentication] [-UseDefaultCredentials] [-SkipCertificateCheck] [-DisableKeepAlive] [-ProxyUseDefaultCredentials] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation]

If we check the Invoke-Webrequest syntax, PowerShell 7.1 version supports the 4 sets for this command.

The other 3 sets include the below extra parameters.



This means that you can not combine the above 2 parameters with the First set of certain parameters. For example, you can’t use the -Proxy and -NoProxy parameter together but set support the -NoProxy and -CustomMethod both together.

How does PowerShell wget works?

The Invoke-WebRequest was introduced in PowerShell 3.0 onwards and has become very popular for interacting with the webpage.

Wget is the name of the alias of the Invoke-WebRequest command in the PowerShell .Net framework version (v1.0 to 5.1).

Get-Alias -Name wget


While in the Powershell Core version (6.0 onwards), the wget alias name is replaced with the iwr command.

Get-Alias -Definition Invoke-Webrequest


Wget and iwr also have the same supported utility called curl, which is a Unix command but introduced as an alias of the Invoke-Webequest command.

Get-Alias -Definition Invoke-WebRequest


When you parse the web page using the Wget command, a few properties and methods are associated with this command. Let see what those members are.


There are various properties like Headers, Images, links, which you can retrieve directly through the wget command.

In the examples below, we will see how various parameters are supported with the wget command.

Examples of PowerShell wget

Given below are the examples of PowerShell wget:

Example #1

Using the wget command to check the website status

We can check the status of the webpage using the wget (Invoke-WebRequest) command.

wget -Uri $uri


StatusCode 200 means that the site is OK. You can check the various status codes on the wiki page link below.

Example #2

Exception handling in the Wget command.

Programming language uses the try/catch methods for exception handling. In this example, we will handle the non-existence website exception using the same method in PowerShell.



To catch the status code of the message.



Example #3

Downloading a file with the Wget command.

We can download files directly from the internet using the wget command as shown below. We are downloading a Web-based net framework from the MS website in this example, as shown below.

wget -Uri $uri -OutFile “C:tempnetframework.exe” -Verbose


The above command will keep the download file in the C:temp folder with the chúng tôi name.

Example #4

Downloading Images, links from the webpage.

With the wget widget, we can access the images or links from the website directly to the local system, as shown below.

$response = wget -Uri $uri

With the above command, the response from the webpage will be stored in the $Response variable. Thus, we can directly access those properties. But, first, let’s check the images stored on the website.



With some operation on the command above, you can download those images to the particular folder as shown below. It will download all the images from the link to the C:tempWebImages folder.

$imgurl = ($img.Split(‘?’))[0] $imgname = ($imgurl -split ‘/’)[-1] }


Similarly, you can access the links from the website.


Example #5

Converting Rest API content to JSON data using wget.

When we use the rest API to get the website data, that data is generally is in JavaScript Object Notation (JSON) format. Therefore, when we use the Invoke-RestMethod command, it directly converts the output to the JSON format, as shown below.


But using the wget command, we need to use some cmdlets to filter the content and then we can convert to the above output display format.

You will get the same output as the first one.

Example #6

Login to the website using the wget post method.

In the below example, we will use the LinkedIn website to log in using wget forms as shown below.

$form = $response.Forms[1] Write-Output “`n`nWebsite Status: $($r.StatusDescription)”



Wget or Invoke-WebRequest (Curl, iwr) is one of the best command-line tools for webpage scrapping and is used by various developers and scripters to call the APIs, pass, delete, modify, add the information to the APIs or the webpages without using the GUI and also helpful to deal with the various types or webpage errors and reporting purpose.

Recommended Articles

This is a guide to PowerShell wget. Here we discuss How does PowerShell wget work along with the examples and outputs. You may also have a look at the following articles to learn more –

How Does The Format Tag Work In Jsp With Examples?

Introduction to JSP format

Web development, programming languages, Software testing & others


Some dependent libraries should be included in the project’s lib folder as the format tag has dependencies in the JSTL library. You can either link a full set of libraries in jSTL or can target specific files as per your purpose. Two statements to be written before start writing the code to use the format tag are:

The prefix denotes the format one would like to use. One can get a complete list of “prefixes” with uri the same as above as per the requirements.

The syntaxes used by JSP Format are:

How does the format tag work in JSP?

JSP Format uses the JSTL library to use the inbuilt formatting options incorporated in predefined format tags with the help of various formats. The prerequisite to use formatting in JSP is that libraries should be attached and present in the lib folder of your project. The syntax above contains some of the common property names. Formatting can be done to match up the existing standards with the help of inbuilt properties, but sometimes the format is local; for example, we want a pricing rate format to be 1 rupee per word, i.e. “1/word”. To save this format, a new pattern or a local xml database has to be created. While just showing the time from “timestamp” is more of formatting from the existing pattern. These are explained in more detail with the help of examples provided in the below section.

Examples of JSP format

Some of the examples to demonstrate the use of the JSP format tag in JSP is explained below for a better understanding of the topic.

Example #1

Here is one of the items on the list, along with its price. The list in the background is a customized list along with its defined pricing style.


Example #2

Code : NewFile2.jsp


Explanation: This is an example of the pre-existing format used to display the inputted information in the applied format. The “fmt:parseDate” helps in identifying the use of formatter in JSP, which is dependent on the JSTL library. “Vale” attributes get the value to be passed into this tag, the “pattern” attribute helps JSP understand the pattern being inputted in the program, and the “var” attribute is used to identify the formatted data, which will be outputted. After the date is passed as input to this tag, then the output is provided in the form of string date and time. This pattern can be seen in the output screen.


JSP format is an easy tag that comes with many functionalities offered by JSP libraries, but it can be complex if looking for a customized, unique data format. Its simplicity does not outweigh the importance attached to this tag. This tag is used very commonly in many websites or businesses linked to finance, export, transportation, agriculture, and many more such sectors.

Recommended Articles

This is a guide to the JSP format. Here we discuss How does the format tag work in JSP and Examples, along with the codes and outputs. You may also have a look at the following articles to learn more –

Update the detailed information about How Does Ansible Firewalld Works With Examples on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!