morst.blogg.se

Galaxy scenario file differs from host
Galaxy scenario file differs from host










In this case, you will define another variable which will restrict the installation of Apache to Ubuntu servers on version 18.04. Suppose you only want Ansible to install apache web server on Ubuntu servers whose version is 18.04, how would you go about it? You can further refine your playbook and narrow it down to the specifics. Using ‘when’ with the logical AND operator Ultimately, the Apache Web Server will be installed on both Red Hat and Debian based servers. This implies that the apache2 package will be installed in all systems that fall under the Debian family, for which Ubuntu is a part. The second play executes the installation of the Apache2 package using the apt package manager which is the native package manager for the Debian OS family.

galaxy scenario file differs from host

In effect skips the installation on Ubuntu server, which is evidenced by the line “ skipping ”īecause the Ubuntu server has been omitted in the first play, another play needs to be defined. This has been defined by the built-in variable ansible_os_family. Because we have defined all the host systems in our inventory, the installation of the httpd package alongside other dependencies will only take place for servers belonging to the Red Hat family. The first task or play executes the installation of the httpd package, colloquially known as the Apache web-server, on the remote CentOS host using the yum package manager which is the package manager for RHEL distros. When you run the playbook, you’ll get the output below Given the differences mentioned, we are going to use the ‘ when’ conditional statement to install Apache web server as shown in the playbook as shown:. In such a scenario, where we have different variables at play, a conditional statement is crucial.

galaxy scenario file differs from host galaxy scenario file differs from host galaxy scenario file differs from host

Both use different package managers and the Apache package also differs in both cases. Installation of Apache on CentOS, which is a Red Hat flavor, differs from Ubuntu, which is a Debian flavor. The task at hand will be to install the Apache web server on both web servers using a single playbook. Using the Ansible Control node which has already been set up and configured to communicate with the two servers. Let’s take an example of a setup with an Ansible control node and two servers as shown below:












Galaxy scenario file differs from host