Skip to content

Instantly share code, notes, and snippets.

@max-arnold
Last active Mar 23, 2020
Embed
What would you like to do?
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