################################################################################ OFFICIAL UBUNTU REPOS ###################################################################################### Ubuntu Main Reposdeb http://nl.archive.ubuntu.com/ubuntu/ {{ ansible_distribution_release }} main restricted universe multiverse###### Ubuntu Update Reposdeb http://nl.archive.ubuntu.com/ubuntu/ {{ ansible_distribution_release }}-security main restricted universe multiversedeb http://nl.archive.ubuntu.com/ubuntu/ {{ ansible_distribution_release }}-updates main restricted universe multiverse###### Ubuntu Partner Repodeb http://archive.canonical.com/ubuntu {{ ansible_distribution_release }} partnerdeb-src http://archive.canonical.com/ubuntu {{ ansible_distribution_release }} partner###### Ubuntu Opsview Repodeb https://XXXXXX:XXXX...@downloads.opsview.com/opsview-commercial/latest/apt {{ ansible_distribution_release }} main{% for item in extra-apt-lines %}{{ item }}{% endfor %}
---extra-apt-lines:- deb http://oss.oracle.com/debian unstable main non-free
---- name: APT | Kopieer apt-sources configaction: template src=~/playbooks/templates/sources.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644notify:- reload apttags:- apt
fatal: [xmgtansible] => {'msg': "unsupported operand type(s) for -: 'Undefined' and 'Undefined'", 'failed': True}
Hi,
> <snip>
Mark Maas wrote:
> Hi List,
>
> I'm currently trying to roll out a default /etc/apt/sources.list and add
> "deb" lines to it for specific hosts.
>
> The template sources.j2 looks like this:
>
> {% for item in extra-apt-lines %}You can't have - in variable names. It's an operator. Name it
extra_apt_lines or something instead, and things should be fine.
> The template sources.j2 looks like this:
>
> <snip>
> {% for item in extra-apt-lines %}
You can't have - in variable names. It's an operator. Name it
extra_apt_lines or something instead, and things should be fine.
You can't have those in variable names, and it's a little weird to do
with Ansible's shorthand templating, but nothing wrong with:
{{ hostvars[$inventory_hostname]["whatever variable name you
want"]["some subkey"] }}
Should work.
Though IMHO the setup module should replace any "-" or "." with "_" to
simplify this problem.
On Tue, Dec 4, 2012 at 2:52 PM, Arie Skliarouk <skli...@gmail.com> wrote:
>> > The template sources.j2 looks like this:
>>
>> >
>> > <snip>
>> > {% for item in extra-apt-lines %}
>>
>> You can't have - in variable names. It's an operator. Name it
>> extra_apt_lines or something instead, and things should be fine.
>
>
> Sorry for hijacking the thread, but looks like it already have been
> resolved...
>
> On one of my machines I have bonded network interface that happens to be
> named "main-net0". Yes, with a dash in the middle. Now, one of my templates
> requires IP number of the interface. This means to get the IP I need to
> address ansible_main-net2.ipv4.address variable. And this causes the same
> "unsupported operand type" error.
>
> How can I workaround the problem?
>
>> > fatal: [xmgtansible] => {'msg': "unsupported operand type(s) for -:
>> > 'Undefined' and 'Undefined'", 'failed': True}
>>
> --
>
>
--