[scl.org] SCL and Ansible ?

Rob Wissmann robwiss at gmail.com
Fri Oct 11 13:33:18 UTC 2019


 Pavel's approach should work fine. Here are two other approaches I've seen
used.

1. Run a playbook that installs the enable script
(/opt/rh/devtoolset-8/enable) into /etc/profile.d. Then, in another
playbook do the stuff you want to do. The second playbook will run as a new
ssh login which means it will pick up the enable actions from the
/etc/profile.d/ script. If you do this, you also need to fix the devtoolset
sudo script because it's broken and doesn't properly forward arguments to
the actual sudo program. I have a working version.
2. Install the devtoolset tools you want then configure the system using
the "alternatives" program to make it so that the devtoolset versions are
the ones that are run. The ansible module for alternatives doesn't work
great though. Specifically, it won't update the settings once they've been
set, or if it does, I couldn't easily figure out how.

On Fri, Oct 11, 2019 at 7:35 AM Pavel Valena <pvalena at redhat.com> wrote:

> ----- Original Message -----
> > From: viscapi at cines.fr
> > To: sclorg at redhat.com
> > Cc: "caux" <caux at cines.fr>
> > Sent: Friday, October 11, 2019 11:22:46 AM
> > Subject: [scl.org] SCL and Ansible ?
> >
> > Dear all,
> >
> > Silly question: is there a way to call "scl enable" from within an
> Ansible
> > role ?
> >
> > So far we've been trying the command, shell and scripts modules, but to
> no
> > avail...
> >
> >
> https://docs.ansible.com/ansible/latest/modules/command_module.html#command-module
> >
> https://docs.ansible.com/ansible/latest/modules/shell_module.html#shell-module
> >
> https://docs.ansible.com/ansible/latest/modules/script_module.html#script-module
> >
> > Here are some failed attempts:
> >
> > - name: Start using the software collection for maven
> >   shell: scl_enabled rh-maven35
> >   register: swap_exists
> >   ignore_errors: true
> > #script: test.sh
> >  # shell: scl enable /etc/scl/conf//opt/rh/rh-maven35 bash && echo toto
> >  #shell: /usr/bin/scl enable rh-maven35 bash
> >  # args:
> >  #   warn: yes
> >  #   chdir: "{{ path_to_pastis }}"
> >   #easy_install:
> >   #  name: scl
> > #  args:
> > #    executable: "/usr/bin/scl enable rh-maven35 bash"
> >  # command: |
> >  #   /usr/bin/scl enable rh-maven35 bash
> > #bash
> >  # shell: |
> >  #   scl enable rh-maven35 bash
> > #bash
> > #  args:
> > #    executable: /bin/bash
>
> Hello,
>
> I'm no ansible expert, but couldn't you run the command you wan't like so:
>
>   shell: /usr/bin/scl enable rh-maven35 -- /path/to/prog/or/scriplet
> arguments...
>
>
> Alternatively, though unsupported probably, you could try `. scl_source`;
> f.e.:
>
> ```
> $ ruby -v ; . scl_source enable rh-ruby25 ; ruby -v
> ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
> ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
>
> ```
>
> HIH,
> Pavel
>
> >
> > I think the root issue is that, as far as I understand, "scl enable"
> starts a
> > new shell and sources environment variables in there, while Ansible is
> still
> > waiting for some RC in the parent shell. Thus Ansible is not really
> failing,
> > but just keeps on waiting for ever...
> >
> > Any help would be greatly appreciated.
> >
> > Best regards,
> >
> > Samuel from CINES
> >
> > https://www.cines.fr/en/
> >
> > --
> >
> > Samuel VISCAPI
> >
> > +33(0)4 67 14 14 36
> > viscapi at cines.fr
> > IM: sviscapi (Skype)
> >
>
> --
> Pavel Valena
> Software Engineer, Red Hat
> Brno, Czech Republic
>
> _______________________________________________
> SCLorg mailing list
> SCLorg at redhat.com
> https://www.redhat.com/mailman/listinfo/sclorg
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/sclorg/attachments/20191011/74265607/attachment.htm>


More information about the SCLorg mailing list