Last active
March 23, 2020 08:11
-
-
Save max-arnold/8a077ae67d3ab2faaf1bef0e9094b146 to your computer and use it in GitHub Desktop.
Rename a Salt minion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save into salt://rename.sls then run the following command: | |
# salt-run state.orch rename pillar='{"old": "OLD_NAME", "new": "NEW_NAME"}' | |
# | |
# For more tips like this, follow https://twitter.com/SaltTips | |
{% set old_name = pillar['old'] %} | |
{% set new_name = pillar['new'] %} | |
Rename minion id: | |
salt.function: | |
- name: file.write | |
- tgt: '{{ old_name }}' | |
- arg: | |
- /etc/salt/minion_id | |
- '{{ new_name }}' | |
Restart minion: | |
salt.function: | |
- name: cmd.run | |
- tgt: '{{ old_name }}' | |
- arg: | |
- 'salt-call service.restart salt-minion' | |
- kwarg: | |
bg: true | |
Rename minion key: | |
module.run: | |
- file.rename: | |
- '/etc/salt/pki/master/minions/{{ old_name }}' | |
- '/etc/salt/pki/master/minions/{{ new_name }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save into salt://rename_win.sls then run the following command: | |
# salt-run state.orch rename_win pillar='{"old": "OLD_NAME", "new": "NEW_NAME"}' | |
# | |
# For more tips like this, follow https://twitter.com/SaltTips | |
{% set old_name = pillar['old'] %} | |
{% set new_name = pillar['new'] %} | |
Rename minion id: | |
salt.function: | |
- name: file.write | |
- tgt: '{{ old_name }}' | |
- arg: | |
- 'C:\\salt\\conf\\minion_id' | |
- '{{ new_name }}' | |
Restart minion: | |
salt.function: | |
- name: cmd.run | |
- tgt: '{{ old_name }}' | |
- arg: | |
- 'C:\\salt\\salt-call.bat service.restart salt-minion' | |
- kwarg: | |
bg: true | |
Rename minion key: | |
module.run: | |
- file.rename: | |
- '/etc/salt/pki/master/minions/{{ old_name }}' | |
- '/etc/salt/pki/master/minions/{{ new_name }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment