On Wed, Nov 08, 2017 at 09:58:32PM +0100, Kai Stian Olstad wrote:
> On 08.11.2017 20:47, Marc Haber wrote:
> > When I change a system from testing to stable, I want the all
> > testing*.list to vanish, and the stable*.list files to appear, unless
> > they're already there, in which case I want them untouched. Locally
> > placed files should also be untouched.
>
> How you can implement this depends on the feature you need
> 1. one server having a several repo stable, testing and unstable
> 2. one server only having stable, testing or unstable.
2, but with execptions. The general function that I want is "zap
everything matching a glob, execpt files that would be written to by
another task"
> > My first approach was to concentrate all the ansible-managed *.list
> > files under a common prefix, zda, giving, for example,
> > zda-unstable.list.
> >
> > I then wrote code to first remove all zda*.list files (and their
> > laegacy-named
> > instances), and code to deploy the correct zda-foo.list file:
> >
> > - name: search for sources.list files
> > find:
> > paths: "/etc/apt/sources.list.d"
> > patterns:
> > "zda-*.list,exp-mc.list,sid-mc.list,sid-zg-stable-mc.list,sid-zg-unstable-mc.list,stretch-mc.list,stretch-security.list,stretch-zg-stable-mc.list,stretch-zg-unstable-mc.list,buster-mc.list,stretch-zg-stable-mc.list,stretch-security.list"
> > register: sourceslistfiles
> > - name: delete sources.list files
> > file:
> > path: "{{ item.path }}"
> > state: absent
> > with_items: "{{ sourceslistfiles.files }}"
>
> To clean up legacy I would only run this once and after that make Ansible do
> the work.
I also want to clean up uncontrolled growth as a continuous process, and
I want to be able to switch a host from one distribution to another with
the files belonging to the "old" one cleaned up automatically.
> Feature 1 only need one variable, call it "repo_type", this could contain
> stable, testing or unstable.
>
> Then your tasks would look something like this
>
> - apt_repository:
> repo: deb http://debian.debian.zugschlus.de/debian/ stretch main contrib
> filename: zda-stretch-mc
> state: "{{ (repo_type == 'stable') | ternary('present', 'absent') }}"
Probably a workaround if the really nice solution can not be had. The
few hosts that have multple repositories would get the extra repos
outside of ansible. I think I can live with that, but it's not pretty.
> With feature 2 you could have something like stable_state, testing_state and
> unstable_state and set them to absent or present, and then just use that
> variable in state.
Also, rather ugly.
But I have to admit that my sense of prettiness is not yet tuned to
ansible.
Greetings
Marc
--
-----------------------------------------------------------------------------
Marc Haber | "I don't trust Computers. They | Mailadresse im Header
Leimen, Germany | lose things." Winona Ryder | Fon: *49 6224 1600402
Nordisch by Nature | How to make an American Quilt | Fax: *49 6224 1600421
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20171109101740.e5hzjtkbmachcsi2%40torres.zugschlus.de.
For more options, visit https://groups.google.com/d/optout.