Skip to content

Instantly share code, notes, and snippets.

@max-arnold
Last active March 23, 2020 08:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max-arnold/8a077ae67d3ab2faaf1bef0e9094b146 to your computer and use it in GitHub Desktop.
Save max-arnold/8a077ae67d3ab2faaf1bef0e9094b146 to your computer and use it in GitHub Desktop.
Rename a Salt minion
# 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 }}'
# 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