DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

SaltStack - Apache Formula for Debian OS Family

Take a look at how you can set up your Apache formula and tear it down with this quick tutorial on your Debian OS system.

Mahesh Shekhar user avatar by
Mahesh Shekhar
·
Sep. 07, 18 · Tutorial
Like (1)
Save
Tweet
Share
2.70K Views

Join the DZone community and get the full member experience.

Join For Free

Salt Stack – Apache Formula

As the blog specifies, here we are going to discuss the Apache formula which installs Apache on the Debian systems. Firstly, let’s discuss the requirements and then see the implementation of the formula.

Let’s say that we have a small set of Debian servers which is salted. We want to install Apache, wherein we have a custom configuration file with the necessary ports and user groups.

So, when we look at the requirements we will understand that our Apache formula should consist of an init state, a restart state, and a config file management state. What does each of them do?

  • Init.sls – In init state, we are going to install the Apache package, start the package, and make sure it is in running state

  • Config.sls – In config.sls, we are going use the salt function file.managed for managing all our files via Salt.

  • Restart.sls – Why do we need restart.sls?

Basically whenever there is change in the config file, we would need to restart the service in order for the changes to take effect.

The file_roots determines where the state files are stored. By default, all of the state files should reside at the location /srv/salt. If you would like to choose a different directory change the location in the /etc/salt/master file.

Let Jump Into Implementation

Firstly, make sure the file_roots is updated to /srv/salt in /etc/salt/master file.

file_roots

Now, let's create a directory, /srv/salt. Let navigate to that directory and create a folder called apache. This is the folder where we will have our state files.

You can download the files from the GitHub repository.

Init.sls

Here we are installing the Apache package and starting the service.

init.sls

Config.sls

  • We will be using the file.managed function to update the apache2.conf file. The source file will be usnder the /apache/debian-apache2.conf

Apache_config_file

dsWhenever there is config changes made to the Apache configuration file, our Apache service needs to be restarted. Here we are going to use the watch state to check if there are any changes made to the apache conf file.

restart.sls

Make sure to copy the debian-apache2 config file in the apache/config folder of master.

Now it’s the time to use the formula. To test the formula, use the command with sudo permissions:

 sudo salt “web1” state.sls apache,apache.config,apache.restart , where web1 is the hostname of your minion)

salt state

Here we can see that there is a change that needs to be updated for the apache configuration file.

To apply the salt formula just remove the option:

 sudo salt “web1” state.sls apache,apache.config,apache.restart .

Debian

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Spring Cloud: How To Deal With Microservice Configuration (Part 1)
  • Load Balancing Pattern
  • How To Use Terraform to Provision an AWS EC2 Instance
  • Continuous Development: Building the Thing Right, to Build the Right Thing

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: