Step #05 : Install OpenERP using a SaltStack state file


We finished the previous step, Install SaltStack master and minion, with a Salt minion accepted for communication with a Salt master.

Now, at last, we can install OpenERP using the "stack" for that purpose published here : FleetingCloud's SaltStack Tool Set on github.com.

Why SaltStack?

Salt requires a bit of conceptual understanding. So here goes...

The point of Salt is to offer a standard declarative language for preparing machines to serve their intended purpose.  As much as possible it hides differences between operating systems.

In this code fragment we see how to customize the PostgreSQL configuration file:
        - blockreplace
        - name: /etc/postgresql/9.1/main/postgresql.conf
        - marker_start: "# START SaltStack managed zone -DO-NOT-EDIT- -----"
        - marker_end: "# END SaltStack managed zone -----------------------"
        - prepend_if_not_found: True
        - backup: '.bak'
        - show_changes: True

        - filename: /etc/postgresql/9.1/main/postgresql.conf
        - name: postgresql-accum
        - text: "listen_addresses='{{ grains['ip_interfaces']['eth0'][0]}}'"
        - require_in:
            - file: postgresql.conf

The first of the two sections sets up a "managed zone" at the beginning of the file /etc/postgresql/9.1/main/postgresql.conf. The require_in phrase of the second section says that the postgresql.conf state should include the "listen_addresses" configuration item. In Salt, "grains" are named attributes of the minion. So, for example, the grain "ip_interfaces" is a list of interfaces on the minion. Listed item "eth0" has an array of attributes of which the first ("0th") is the IP address that PostgreSQL needs to be told about. 

All this may seem like a very verbose and roundabout way of patching a file, but it is advantageous because of platform independence .  Also, once you are familiar with the syntax it becomes much more readable that reams of bash script.

Finally, the main advantage is that it can all be kept on a single master server, and pushed out to hundreds or thousands of minion machines according to a wide variety of targeting and filtering rules.

The /srv Symbolic Link

While Salt's minion targeting is very powerful, it is very advanced usage.  For this video series I have placed each installation state stack in a separate named directory of SaltStackToolSet.  Each one has a single immediate subdirectory named "srv".  For each installation run of salt "*" state.highstate I simply set a symbolic link from Salt's default state stack directory named "/srv".  Not recommended for production, but clear and simple for an introductory video.

Here's the video:

Note correction:  Please refer to Update on recent changes to Video #5 for errata updates.

Tasks performed

  1. Go to GitHub to get the URL of zip'd FleetingClouds / SaltStackToolSet.
  2. Download and unzip the tools.
  3. Rename the directory to SaltStackToolSet
  4. Copy the example pillar file and edit the new one with the correct configuration parameters for OpenERP.
  5. Set up a symbolic link from Salt's default state stack directory ("/srv") to the "srv" directory of our OpenERP tool.
  6. Run salt 
  7. Restart the minion
  8. Test that OpenERP is working.
An overview of all the steps is available here:

No comments:

Post a Comment