Skip to content

WP_CLI conditional gets repeatedly applied #41

@kadamwhite

Description

@kadamwhite

Due to the changes in PR #35 which break the wp-settings.php require out into a multi-line if statement, repeated provisioner runs add more and more surrounding if statements. I attempted to play with the file_line configuration for about an hour but couldn't find any combination of flags or changes to the match value that would prevent that.

I then tried replacing that resource with a sed call:

	exec { 'adjust chassis wp-config.php':
		# Replace
		#     require_once( ABSPATH . 'wp-settings.php' );
		# with
		#     if ( ! defined( 'WP_CLI' ) ) {
		#         require_once( ABSPATH . 'wp-settings.php' );
		#     }
		# but only once.
		command => "sed -i 's|^require_once.*ABSPATH.*wp-settings.*|if ( ! defined( 'WP_CLI' ) ) {\n\trequire_once( ABSPATH . '\''wp-settings.php'\'' );\n}|g' /vagrant/wp-config.php",
		path    => ['/bin'],
		user    => 'vagrant',
		before  => Chassis::Wp[ $config['hosts'][0] ],
	}

but that (while it works on the command line) fails in puppet with the error

==> default: Notice: /Stage[main]/Core_dev::Config/Exec[adjust chassis wp-config.php]/returns:
/bin/sed: -e expression #1, char 68: unterminated `s' command

This is annoying, but it's not the end of the world, so I'm going to cut off my troubleshooting and open this issue to revisit instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions