On 10.03.2019 15:34, liverpudlian88 wrote:
> Hello, Any help please?
A lot of fundamental problems. I'll try to address them all.
> On Saturday, March 9, 2019 at 3:18:21 AM UTC+2, liverpudlian88 wrote:
>>
>> Hello,
>>
>> I am kinda new to Ansible, I would appreciate if you could assist me
>> with
>> a question, I am trying to do the following in a role in a playbook
>>
>> 1- Copy 3 zip files to a specific destination
>> 2- Unzip only the first
>> 3- Rename a directory in the unzipped location
>> 4- Unzip the remaining 2 files
>>
>> I mainly have 2 problems, the first is that only the first file is
>> copied
>> and second the when condition is apparently not written correctly
This is not very helpful and probably the reason you haven't gotten an
answer (plus is a weekend).
You should always provide the full output of the run, very hard to help
without since it takes a lot more time.
>> This is my list in the role's default directory
>> installer_archives:
>> - { name: V978971-01.zip, dest: "{{oracle_home_gi}}" }
>> - { name: p28828717_180000_Linux-x86-64.zip, dest:
>> "{{oracle_stage}}" }
>> - { name: p6880880_121010_Linux-x86-64.zip, dest:
>> "{{oracle_home_gi}}" }
>>
>> This is my role:
>> # ==> Copy installer files
>> - name: Copy installer files
>> copy:
>> src: '{{ item }}'
>> dest: '{{ oracle_stage }}/'
>> owner: '{{ grid_install_user }}'
>> mode: 0644
>> group: '{{ oracle_group }}'
>> with_items: '{{ installer_archives }}'
>> when: ansible_hostname==groups[group_names | first] | first
Every item will contain a dict with two keys,
item.name and item.dest.
You are here using item that will contain both key and value.
I guess you are after
item.name in your src: and not both of them since
that make no sense.
>> - name: install-home-gi | Extract files to ORACLE_HOME (gi)
>> unarchive:
>> src: '{{ oracle_stage }}/{{ item }}'
>> dest: '{{ item.dest }}'
>> copy: no
>> owner: '{{ grid_install_user }}'
>> group: '{{ oracle_group }}'
>> with_items: '{{installer_archives}}'
>> args:
>> creates: '{{ oracle_home_gi }}/root.sh'
>> when: ansible_hostname==groups[group_names | first] | first and
>> "{{installer_archives}}" | first
Same here, your item is a dict and your are probably looking for
item.name and not just item.
>> - name: install-home-gi | Move old Opatch directory
>> shell: "mv {{ oracle_home_gi }}/OPatch {{ oracle_home_gi
>> }}/OPatch.old"
>>
>> - name: install-home-gi | Extract Opatch and BP
>> unarchive:
>> src: '{{ oracle_stage }}/{{
item.name }}'
>> dest: '{{ item.dest }}'
>> copy: no
>> owner: '{{ grid_install_user }}'
>> group: '{{ oracle_group }}'
>> with_items: '{{installer_archives}}'
>> when: ansible_hostname==groups[group_names | first] | first and not
>> {{installer_archives}} | first
Here you actually have
item.name and this is probably the only task that
works.
--
Kai Stian Olstad