Thank you Daniel! We'll try this out when all of our code is ready, and will report back here with any issues we hit etc in case somebody else comes across this thread. Looks like this should work in a sandbox experiment.
On Wednesday, 29 November 2017 08:54:56 UTC, Daniel Lobato wrote: > > On 11/28, 'Tom Farrow' via Foreman users wrote: > > Thank you Daniel, this does indeed look like our best approach. > > > > A concern I do have is with "search_for". We also have an > apache_activemq > > module, and it is important that this is not affected by the query. Is > > there a way to specify the search using regex? > > I see. "search_for" is literally the method used in the web UI to search. > If you want to use a regex, I think it'd be more appropriate to do > something like: > > classes = Puppetclass.unscoped.select { |klass| /(^apache(::)+|^apache$)/ > =~ klass } > classes.each do |puppetclass| > new_name = puppetclass.name.sub('apache', 'legacy_apache') > puppetclass.update_attributes(:name => new_name) > end > > This will match all 'apache::' classes, so 'apache_activemq::' will not > be matched. > > You can experiment with the regex here http://rubular.com/ > > > > > > > On Monday, 27 November 2017 14:47:16 UTC, Daniel Lobato wrote: > > > > > > On 11/27, 'Tom Farrow' via Foreman users wrote: > > > > Hi, > > > > > > > > We'd like to rename a couple of classes, retaining all parameter > > > overrides > > > > etc. > > > > > > > > We're looking to move "::apache" to "::legacy_apache" including all > > > other > > > > classes within the module (::apache::mod::python etc). > > > > > > > > To me, the workflow seems to be: > > > > - Change code to use the new name > > > > - In the Foreman database, change the class names in the > `puppetclasses` > > > > table (ie, update `puppetclasses` set `name` = 'apache' where > `id`='15') > > > > > > > > Do we need to change the class name anywhere else? It looks like > Foreman > > > > always references via this table for lookups, but I may be mistaken. > > > > > > > > Is there a nicer way to do this? Maybe via foreman-console? > > > > > > Via foreman-console, you'd also ensure any references get updated. I > would > > > not > > > recommend doing any updates updating the db rows directly. > > > > > > Also Puppetclasses in Foreman just have one attribute, 'name', no > > > inheritance > > > or anything like that. You will have to update classes that look like > > > apache > > > to legacy_apache. > > > > > > For example, through the console: > > > > > > Puppetclass.search_for("apache").each do |puppetclass| > > > new_name = puppetclass.name.sub('apache', 'legacy_apache') > > > puppetclass.update_attributes(:name => new_name) > > > end > > > > > > Obviously test in a sandbox first, but I was able to rename the class > in > > > the > > > same way. I imagine the reason you want to do this is to preserve your > > > overrides, > > > correct? > > > > > > > > > > > > > > Thanks for your help in advance > > > > Tom > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > > > Groups "Foreman users" group. > > > > To unsubscribe from this group and stop receiving emails from it, > send > > > an email to foreman-user...@googlegroups.com <javascript:>. > > > > To post to this group, send email to forema...@googlegroups.com > > > <javascript:>. > > > > Visit this group at https://groups.google.com/group/foreman-users. > > > > For more options, visit https://groups.google.com/d/optout. > > > > > > > > > -- > > > Daniel Lobato Garcia > > > > > > @dLobatog > > > blog.daniellobato.me > > > daniellobato.me > > > > > > GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30 > > > Keybase: https://keybase.io/elobato > > > > > > > -- > > You received this message because you are subscribed to the Google > Groups "Foreman users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to foreman-user...@googlegroups.com <javascript:>. > > To post to this group, send email to forema...@googlegroups.com > <javascript:>. > > Visit this group at https://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/d/optout. > > > -- > Daniel Lobato Garcia > > @dLobatog > blog.daniellobato.me > daniellobato.me > > GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30 > Keybase: https://keybase.io/elobato > -- You received this message because you are subscribed to the Google Groups "Foreman users" group. To unsubscribe from this group and stop receiving emails from it, send an email to foreman-users+unsubscr...@googlegroups.com. To post to this group, send email to foreman-users@googlegroups.com. Visit this group at https://groups.google.com/group/foreman-users. For more options, visit https://groups.google.com/d/optout.