saltstack/salt — pull request #2849 by rrada (2012-12-09 21:25:11+00:00)
Title: State and module for alternatives system

Hey guys,

I've just finished state and module for some simple control over the alternatives system. Currently you can install, remove and display the alternatives. I need this one to change the default path of Hadoop configuration path(it's set from package). Here is the overview how it works.

**alternatives.display**:
```bash
# salt "minion" alternatives.display hadoop-0.20-conf
minion: hadoop-0.20-conf - auto mode
minion: link currently points to /etc/hadoop-0.20/conf.empty
minion: /etc/hadoop-0.20/conf.empty - priority 10
minion: Current 'best' version is '/etc/hadoop-0.20/conf.empty'.
```

**alternatives.install**:
```bash
# salt "minion" alternatives.install hadoop-0.20-conf /etc/hadoop-0.20/conf /opt/hadoop/conf 60
minion: update-alternatives: using /opt/hadoop/conf to provide /etc/hadoop-0.20/conf (hadoop-0.20-conf) in auto mode.
```

**alternatives.remove**:
```bash
# salt "minion" alternatives.remove hadoop-0.20-conf /www/hadoop/conf
minion: update-alternatives: using /etc/hadoop-0.20/conf.empty to provide /etc/hadoop-0.20/conf (hadoop-0.20-conf) in auto mode.
```

State usage:
```yaml
hadoop-0.20-conf:
alternatives.install:
- name: hadoop-0.20-conf
- link: /etc/hadoop-0.20/conf
- path: /opt/hadoop/conf
- priority: 30

hadoop-0.20-conf:
alternatives:
- remove
- name: hadoop-0.20-conf
- path: /opt/hadoop/conf
```

I hope it helps to someone else too.