All of lore.kernel.org
 help / color / mirror / Atom feed
* aarch64 conditional ansible stanza
@ 2016-04-07  6:46 Loic Dachary
  2016-04-07 13:58 ` Thierry Delamare
  0 siblings, 1 reply; 6+ messages in thread
From: Loic Dachary @ 2016-04-07  6:46 UTC (permalink / raw)
  To: Thierry Delamare; +Cc: Ceph Development

Hi Thierry,

In order to only install a template on architectures that are not aarch64, I changed

- name: Add sources list
  template:
    dest: /etc/apt/sources.list
    src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
    owner: root
    group: root
    mode: 0644
  register: sources

into

- name: Add sources list
  template:
    dest: /etc/apt/sources.list
    src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
    owner: root
    group: root
    mode: 0644
  register: sources
  when: {{ansible_architecture}} != aarch64

Is there a better way to do that ?

Cheers

-- 
Loïc Dachary, Artisan Logiciel Libre
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: aarch64 conditional ansible stanza
  2016-04-07  6:46 aarch64 conditional ansible stanza Loic Dachary
@ 2016-04-07 13:58 ` Thierry Delamare
  2016-04-07 14:07   ` Loic Dachary
  0 siblings, 1 reply; 6+ messages in thread
From: Thierry Delamare @ 2016-04-07 13:58 UTC (permalink / raw)
  To: Loic Dachary; +Cc: Ceph Development



On 04/07/2016 08:46 AM, Loic Dachary wrote:
> Hi Thierry,
>
> In order to only install a template on architectures that are not aarch64, I changed
>
> - name: Add sources list
>    template:
>      dest: /etc/apt/sources.list
>      src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>      owner: root
>      group: root
>      mode: 0644
>    register: sources
>
> into
>
> - name: Add sources list
>    template:
>      dest: /etc/apt/sources.list
>      src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>      owner: root
>      group: root
>      mode: 0644
>    register: sources
>    when: {{ansible_architecture}} != aarch64
>
> Is there a better way to do that ?
Bonjour Loic,

Using when statement is the correct way to add conditions to a task,
but don't forget that the when clause contains a Jinja2 expression (not 
like a module argument),
Thus the correct expression should rather be « when: 
ansible_architecture != 'aarch64' ».

a+


--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: aarch64 conditional ansible stanza
  2016-04-07 13:58 ` Thierry Delamare
@ 2016-04-07 14:07   ` Loic Dachary
  2016-04-07 15:49     ` Thierry Delamare
  0 siblings, 1 reply; 6+ messages in thread
From: Loic Dachary @ 2016-04-07 14:07 UTC (permalink / raw)
  To: Thierry Delamare; +Cc: Ceph Development



On 07/04/2016 15:58, Thierry Delamare wrote:
> 
> 
> On 04/07/2016 08:46 AM, Loic Dachary wrote:
>> Hi Thierry,
>>
>> In order to only install a template on architectures that are not aarch64, I changed
>>
>> - name: Add sources list
>>    template:
>>      dest: /etc/apt/sources.list
>>      src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>>      owner: root
>>      group: root
>>      mode: 0644
>>    register: sources
>>
>> into
>>
>> - name: Add sources list
>>    template:
>>      dest: /etc/apt/sources.list
>>      src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>>      owner: root
>>      group: root
>>      mode: 0644
>>    register: sources
>>    when: {{ansible_architecture}} != aarch64
>>
>> Is there a better way to do that ?
> Bonjour Loic,
> 
> Using when statement is the correct way to add conditions to a task,
> but don't forget that the when clause contains a Jinja2 expression (not like a module argument),
> Thus the correct expression should rather be « when: ansible_architecture != 'aarch64' ».

Indeed, the previous attempt failed :-) Here is a more elaborate version that also excludes some packages that are not available in the aarch64 repositories. How does that look ?

https://github.com/ceph/ceph-cm-ansible/pull/224/commits/80e1cb2f3688393f4238268a543e6c3ab19bae75

-- 
Loïc Dachary, Artisan Logiciel Libre
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: aarch64 conditional ansible stanza
  2016-04-07 14:07   ` Loic Dachary
@ 2016-04-07 15:49     ` Thierry Delamare
  2016-04-07 16:09       ` Loic Dachary
  0 siblings, 1 reply; 6+ messages in thread
From: Thierry Delamare @ 2016-04-07 15:49 UTC (permalink / raw)
  To: Loic Dachary; +Cc: Ceph Development



On 04/07/2016 04:07 PM, Loic Dachary wrote:
>
> On 07/04/2016 15:58, Thierry Delamare wrote:
>>
>> On 04/07/2016 08:46 AM, Loic Dachary wrote:
>>> Hi Thierry,
>>>
>>> In order to only install a template on architectures that are not aarch64, I changed
>>>
>>> - name: Add sources list
>>>     template:
>>>       dest: /etc/apt/sources.list
>>>       src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>>>       owner: root
>>>       group: root
>>>       mode: 0644
>>>     register: sources
>>>
>>> into
>>>
>>> - name: Add sources list
>>>     template:
>>>       dest: /etc/apt/sources.list
>>>       src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>>>       owner: root
>>>       group: root
>>>       mode: 0644
>>>     register: sources
>>>     when: {{ansible_architecture}} != aarch64
>>>
>>> Is there a better way to do that ?
>> Bonjour Loic,
>>
>> Using when statement is the correct way to add conditions to a task,
>> but don't forget that the when clause contains a Jinja2 expression (not like a module argument),
>> Thus the correct expression should rather be « when: ansible_architecture != 'aarch64' ».
> Indeed, the previous attempt failed :-) Here is a more elaborate version that also excludes some packages that are not available in the aarch64 repositories. How does that look ?
>
> https://github.com/ceph/ceph-cm-ansible/pull/224/commits/80e1cb2f3688393f4238268a543e6c3ab19bae75
>
That looks good to me, but.
You could also use the already existing scheme for defining vars or even 
including plays depending on distribution or (if you take care of it) 
architecture.
I mean that you could create a 
roles/testnode/tasks/setup-ubuntu-aarch32.yml with only the needed tasks 
(instead of conditionally exclude most of them in 
roles/testnode/tasks/setup-ubuntu.yml) and change 
roles/testnode/tasks/main.yml to add « - { include: 
setup-ubuntu-aarch32.yml, when: ansible_distribution == "Ubuntu" and 
ansible_architecture == 'aarch32' } » (maybe you also want to rename 
setup-ubuntu.yml as setup-ubuntu-aarch64.yml and change main.yml 
accordingly)
If the common part between aarch32 and aarch64 duplicate to much, keep a 
common setup-ubuntu.
Similarly for packages lists (more usual), add 
roles/testnode/vars/ubuntu-aarch64.yml and ubuntu-aarch32.yml for 
respective specific packages and use an include_vars directive using 
ansible_distribution and ansible_architecture once in 
roles/testnode/tasks/vars.yml instead of many when clauses.

PS: Maybe you could teach me how to boostrap a working env next time we 
cowork.


--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: aarch64 conditional ansible stanza
  2016-04-07 15:49     ` Thierry Delamare
@ 2016-04-07 16:09       ` Loic Dachary
  2016-04-07 16:35         ` Thierry Delamare
  0 siblings, 1 reply; 6+ messages in thread
From: Loic Dachary @ 2016-04-07 16:09 UTC (permalink / raw)
  To: Thierry Delamare; +Cc: Ceph Development



On 07/04/2016 17:49, Thierry Delamare wrote:
> 
> 
> On 04/07/2016 04:07 PM, Loic Dachary wrote:
>>
>> On 07/04/2016 15:58, Thierry Delamare wrote:
>>>
>>> On 04/07/2016 08:46 AM, Loic Dachary wrote:
>>>> Hi Thierry,
>>>>
>>>> In order to only install a template on architectures that are not aarch64, I changed
>>>>
>>>> - name: Add sources list
>>>>     template:
>>>>       dest: /etc/apt/sources.list
>>>>       src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>>>>       owner: root
>>>>       group: root
>>>>       mode: 0644
>>>>     register: sources
>>>>
>>>> into
>>>>
>>>> - name: Add sources list
>>>>     template:
>>>>       dest: /etc/apt/sources.list
>>>>       src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>>>>       owner: root
>>>>       group: root
>>>>       mode: 0644
>>>>     register: sources
>>>>     when: {{ansible_architecture}} != aarch64
>>>>
>>>> Is there a better way to do that ?
>>> Bonjour Loic,
>>>
>>> Using when statement is the correct way to add conditions to a task,
>>> but don't forget that the when clause contains a Jinja2 expression (not like a module argument),
>>> Thus the correct expression should rather be « when: ansible_architecture != 'aarch64' ».
>> Indeed, the previous attempt failed :-) Here is a more elaborate version that also excludes some packages that are not available in the aarch64 repositories. How does that look ?
>>
>> https://github.com/ceph/ceph-cm-ansible/pull/224/commits/80e1cb2f3688393f4238268a543e6c3ab19bae75
>>
> That looks good to me, but.
> You could also use the already existing scheme for defining vars or even including plays depending on distribution or (if you take care of it) architecture.
> I mean that you could create a roles/testnode/tasks/setup-ubuntu-aarch32.yml with only the needed tasks (instead of conditionally exclude most of them in roles/testnode/tasks/setup-ubuntu.yml) and change roles/testnode/tasks/main.yml to add « - { include: setup-ubuntu-aarch32.yml, when: ansible_distribution == "Ubuntu" and ansible_architecture == 'aarch32' } » (maybe you also want to rename setup-ubuntu.yml as setup-ubuntu-aarch64.yml and change main.yml accordingly)
> If the common part between aarch32 and aarch64 duplicate to much, keep a common setup-ubuntu.

I did that, it looks better :-)

> Similarly for packages lists (more usual), add roles/testnode/vars/ubuntu-aarch64.yml and ubuntu-aarch32.yml for respective specific packages and use an include_vars directive using ansible_distribution and ansible_architecture once in roles/testnode/tasks/vars.yml instead of many when clauses.

I'm not sure I get where the simplification is. When I try this, I end up with more indirection levels and it feels more complicated.

> PS: Maybe you could teach me how to boostrap a working env next time we cowork.

You should be able to follow the HOWTO at http://dachary.org/?p=3939 when you get a chance :-) Or I'll show you.

Cheers

> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
Loïc Dachary, Artisan Logiciel Libre
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: aarch64 conditional ansible stanza
  2016-04-07 16:09       ` Loic Dachary
@ 2016-04-07 16:35         ` Thierry Delamare
  0 siblings, 0 replies; 6+ messages in thread
From: Thierry Delamare @ 2016-04-07 16:35 UTC (permalink / raw)
  To: Loic Dachary; +Cc: Ceph Development



On 04/07/2016 06:09 PM, Loic Dachary wrote:
>
> On 07/04/2016 17:49, Thierry Delamare wrote:
>>
>> On 04/07/2016 04:07 PM, Loic Dachary wrote:
>>> On 07/04/2016 15:58, Thierry Delamare wrote:
>>>> On 04/07/2016 08:46 AM, Loic Dachary wrote:
>>>>> Hi Thierry,
>>>>>
>>>>> In order to only install a template on architectures that are not aarch64, I changed
>>>>>
>>>>> - name: Add sources list
>>>>>      template:
>>>>>        dest: /etc/apt/sources.list
>>>>>        src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>>>>>        owner: root
>>>>>        group: root
>>>>>        mode: 0644
>>>>>      register: sources
>>>>>
>>>>> into
>>>>>
>>>>> - name: Add sources list
>>>>>      template:
>>>>>        dest: /etc/apt/sources.list
>>>>>        src: "../../templates/apt/sources.list.{{ ansible_distribution_release | lower }}"
>>>>>        owner: root
>>>>>        group: root
>>>>>        mode: 0644
>>>>>      register: sources
>>>>>      when: {{ansible_architecture}} != aarch64
>>>>>
>>>>> Is there a better way to do that ?
>>>> Bonjour Loic,
>>>>
>>>> Using when statement is the correct way to add conditions to a task,
>>>> but don't forget that the when clause contains a Jinja2 expression (not like a module argument),
>>>> Thus the correct expression should rather be « when: ansible_architecture != 'aarch64' ».
>>> Indeed, the previous attempt failed :-) Here is a more elaborate version that also excludes some packages that are not available in the aarch64 repositories. How does that look ?
>>>
>>> https://github.com/ceph/ceph-cm-ansible/pull/224/commits/80e1cb2f3688393f4238268a543e6c3ab19bae75
>>>
>> That looks good to me, but.
>> You could also use the already existing scheme for defining vars or even including plays depending on distribution or (if you take care of it) architecture.
>> I mean that you could create a roles/testnode/tasks/setup-ubuntu-aarch32.yml with only the needed tasks (instead of conditionally exclude most of them in roles/testnode/tasks/setup-ubuntu.yml) and change roles/testnode/tasks/main.yml to add « - { include: setup-ubuntu-aarch32.yml, when: ansible_distribution == "Ubuntu" and ansible_architecture == 'aarch32' } » (maybe you also want to rename setup-ubuntu.yml as setup-ubuntu-aarch64.yml and change main.yml accordingly)
>> If the common part between aarch32 and aarch64 duplicate to much, keep a common setup-ubuntu.
> I did that, it looks better :-)
>
>> Similarly for packages lists (more usual), add roles/testnode/vars/ubuntu-aarch64.yml and ubuntu-aarch32.yml for respective specific packages and use an include_vars directive using ansible_distribution and ansible_architecture once in roles/testnode/tasks/vars.yml instead of many when clauses.
> I'm not sure I get where the simplification is. When I try this, I end up with more indirection levels and it feels more complicated.
I don't say it's the simplest way to get your changes done, but it look 
like more coherent with existing scheme (itself familiar to ansible 
users) and probably will be easier to find and evolve for newcomers 
(main include vars which include version dependent files defining 
version dependent vars)
>   
>
>> PS: Maybe you could teach me how to boostrap a working env next time we cowork.
> You should be able to follow the HOWTO at http://dachary.org/?p=3939 when you get a chance :-) Or I'll show you.
Thanks for the link. I will try.

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-04-07 17:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-07  6:46 aarch64 conditional ansible stanza Loic Dachary
2016-04-07 13:58 ` Thierry Delamare
2016-04-07 14:07   ` Loic Dachary
2016-04-07 15:49     ` Thierry Delamare
2016-04-07 16:09       ` Loic Dachary
2016-04-07 16:35         ` Thierry Delamare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.