[mythtv] Proposed Ansible Changes, Getting ready for ansible 2.11

Bill Meek keemllib at gmail.com
Wed Aug 15 22:26:25 UTC 2018


On 08/15/2018 12:24 AM, David Hampton wrote:
> On Tue, 2018-08-14 at 22:15 -0500, Bill Meek wrote:
>> Hi all,
>>
>> In Ansible 2.5, the 'loop' keyword is now preferred over the
>> 'with_item' keyword.
>> Mythbuntu 16.04 uses 2.0.0.2, Ubuntu 18.04 uses 2.5.1
>>
>> But, both loop and with_* are no longer the keywords of choice for
>> things like apt/yum...

...

>> # NEW (simple case, just one package. Max. is 16):
>> - name: add compilers and build essentials 2 (ubuntu)
>>     set_fact:
>>       deb_pkg_lst:
>>         - '{{ deb_pkg_lst }}'
>>         - libtool-bin
>>     when: ansible_distribution == "Ubuntu" and
>> ansible_lsb.major_release|int >= 15
>>
>> ...
>>
>> # NEW single apt: does all packages (in this main.yml) at once:
>> - name: install mythtv-deb packages
>>     apt:  name={{ lookup('flattened', deb_pkg_lst ) }} state=present
>>
>>
>> Any comments? I'm willing to convert playbooks, starting with mythtv-
>> deb.
>> That's the only thing I've tested (Mythbuntu 16.04 and Ubuntu 18.04.)
>>
>> I've also done another solution by giving names to each set of
>> packages
>> and putting that list in the vars directory alongside of the tasks
>> directory.
>> I think the above is easier to implement and maintain though.
> 
> Seems reasonable.  What's the "max is 16" comment about?

I could have made that clearer. Some tasks just add one package, while others
add lots, the biggest one for the Debian family is currently 16 packages
in one task. Didn't mean to imply a limit.

One package vs. many is important because apt: and other ansible package
modules expect a simple list of packages. We end up with a list of lists
& individual packages which causes ansible-playbook to abort.

The solution is to flatten the list (into a single one.) And it's simple in
ansible 2.5. Just: {{ deb_pkg_lst | flatten }}. In ansible 1.3, this is
available: {{ lookup('flattened', deb_pkg_lst ) }}. Not quite as clean but
hopefully portable for the ansible versions in play.

> I have a bunch of VMs for various distros and would be willing to help
> with the testing.  Probably the oldest release that you need to support
> is 2.0.0 which is used by Ubuntu 16.04.  If Debian Jessie is still a
> supported release, its back at 1.7.2.  Ubuntu 14.04 is even further
> back at 1.5.4, but I believe its no longer officially supported now
> that 18.04 is out.

Thanks for that offer. And the 1.5.4 Ubuntu 14.04 version comment.

-- 
Bill


More information about the mythtv-dev mailing list