Installing WP-CLI, the WordPress Command Line, with SaltStack

  • Service Provider

    This is written for Linux and tested on Fedora 25 but should really work on any UNIX system. This only needs one file and is only dependent on curl which is pretty much everywhere by default, I can't remember ever seeing a system without it. Just create this file on your Salt master and it is all that you need: /srv/salt/wp-cli/init.sls

        - name: |
            cd /tmp
            curl -O
            chmod +x /tmp/wp-cli.phar
            mv /tmp/wp-cli.phar /usr/local/bin/wp
        - cwd: /tmp
        - shell: /bin/bash
        - timeout: 300
        - creates: /usr/local/bin/wp

    With this state file, the latest WP-CLI will be downloaded, set to be executable and placed into the standard command path. Once the state has been applied the wp standard command should be available to you. Perfect for anyone who has followed by SaltStack LAMP Install Guide and is planning to manage WordPress on their LAMP Stack.