I am using elasticsearch-formula
and kibana-formula
together to manage my ELK stack. They both attempt to install different APT repositories in /etc/apt/sources.list.d/elasticsearch.list
. The state they use to do this, pkgrepo.managed
, does not support multiple entries in the same list.
In order to avoid having to clean up my environment, I've reproduced this here using the testing mode.
On the first run, we have
# /etc/apt/sources.list.d/elasticsearch.list
deb http://packages.elastic.co/elasticsearch/2.x/debian stable main
and
----------
ID: elasticsearch_repo
Function: pkgrepo.managed
Name: deb http://packages.elastic.co/elasticsearch/2.x/debian stable main
Result: True
Comment: Package repo 'deb http://packages.elastic.co/elasticsearch/2.x/debian stable main' already configured
Started: 21:31:08.981497
Duration: 105.291 ms
Changes:
----------
ID: kibana-repo
Function: pkgrepo.managed
Name: deb http://packages.elastic.co/kibana/4.6/debian stable main
Result: None
Comment: Package repo 'deb http://packages.elastic.co/kibana/4.6/debian stable main' will be configured. This may cause pkg states to behave differently than stated if this action is repeated without test=True, due to the differences in the configured repositories.
Started: 21:31:14.612941
Duration: 96.899 ms
Changes:
If we carry out these changes, then we see
# /etc/apt/sources.list.d/elasticsearch.list
deb http://packages.elastic.co/kibana/4.6/debian stable main
and applying the states again gives us
----------
ID: elasticsearch_repo
Function: pkgrepo.managed
Name: deb http://packages.elastic.co/elasticsearch/2.x/debian stable main
Result: None
Comment: Package repo 'deb http://packages.elastic.co/elasticsearch/2.x/debian stable main' will be configured. This may cause pkg states to behave differently than stated if this action is repeated without test=True, due to the differences in the configured repositories.
Started: 22:01:19.203244
Duration: 99.405 ms
Changes:
----------
ID: kibana-repo
Function: pkgrepo.managed
Name: deb http://packages.elastic.co/kibana/4.6/debian stable main
Result: True
Comment: Package repo 'deb http://packages.elastic.co/kibana/4.6/debian stable main' already configured
Started: 22:01:25.128232
Duration: 95.166 ms
Changes:
As you can see, we can apply the highstate as many time as we want: the formulas will just keep swapping which repository lives in that file. If we ran the same without test=True
, as I saw before, the one which is executed later always runs.