What is the best way to handle renaming things?
In my case I’ve got domains listed in a data bag and use the apache2
cookbook to create / manage them.
If I need to rename a domain, but keep all its files around, how best
would I do this in an idempotent way?
Should I store the old and current domain name in the data bag and check
if they are different and if so create the new domain, move files, then
delete the old?
I’m more looking for a pattern since I may need to rename databases and
users as well.
–
Steven Barre, RHCE, ZCE, MCP
steven@realestatewebmasters.com
Systems Administrator / Programmer
Real Estate Webmasters - 250-753-9893
On Jul 31, 2013, at 11:38 AM, Steven Barre steven@realestatewebmasters.com wrote:
What is the best way to handle renaming things?
In my case I've got domains listed in a data bag and use the apache2 cookbook to create / manage them.
If I need to rename a domain, but keep all its files around, how best would I do this in an idempotent way?
Should I store the old and current domain name in the data bag and check if they are different and if so create the new domain, move files, then delete the old?
I'm more looking for a pattern since I may need to rename databases and users as well.
Renaming is somewhat inherently not idempotent but the closest you can probably get is
if exists(new)
if exists(old)
remove(old)
update(new)
else
if exists(old)
rename(old, new)
else
create(new)
Each of those 5 operations (exists, rename, create, remove, update) will vary depending on the situation.
--Noah