file name too long when using Ansible command module











up vote
0
down vote

favorite












I am trying to install chef automate using chef habitat with ansible.



here is the related section of main.yml



- name: get aib filename
find:
paths: /home/ec2-user
file_type: file
use_regex: yes
patterns:
- '^automate.*'
register: file_automate

- name: deploy chef-automatev2
command: "sudo chef-automate deploy '/home/ec2-user/config.toml' --accept-terms-and-mlsa --skip-preflight --airgap-bundle '/home/ec2-user/{{ file_automate.files }}'"


but getting error:




TASK [deploy chef-automatev2]
***************************************************************************fatal: [10.1.1.2]: FAILED! => {"changed": true, "cmd": ["sudo",
"chef-automate", "deploy", "/home/ec2-user/config.toml",
"--accept-terms-and-mlsa", "--skip-preflight", "--airgap-bundle",
"/home/ec2-user/[{uuid: 0, uwoth: False, umtime: 1540882069.3233995,
uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg:
True, upw_name: uroot, ugid: 0, uischr: False, uwusr: True, uxoth:
False, uislnk: False, unlink: 1, uissock: False, urgrp: True,
ugr_name: uroot, upath: u/home/ec2-user/automate-20181020020209.aib,
uxusr: False, uatime: 1540882068.8493989, uisdir: False, uctime:
1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo: False, umode: u0644, urusr: True}]"],
"delta": "0:00:00.026909", "end": "2018-10-30 06:48:00.362616", "msg":
"non-zero return code", "rc": 94, "start": "2018-10-30
06:48:00.335707", "stderr": "Error: DeployError: Unable to install,
configure and start the service: Failed to unpack airgap artifact:
Failed to open install bundle file /home/ec2-user/[{uuid: 0, uwoth:
False, umtime: 1540882069.3233995, uinode: 82, uisgid: False, usize:
605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0,
uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
uissock: False, urgrp: True, ugr_name: uroot, upath:
u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
False, umode: u0644, urusr: True}]: open /home/ec2-user/[{uuid: 0,
uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False,
usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid:
0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
uissock: False, urgrp: True, ugr_name: uroot, upath:
u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
False, umode: u0644, urusr: True}]: file name too long",
"stderr_lines": ["Error: DeployError: Unable to install, configure and
start the service: Failed to unpack airgap artifact: Failed to open
install bundle file /home/ec2-user/[{uuid: 0, uwoth: False, umtime:
1540882069.3233995, uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0, uischr: False,
uwusr: True, uxoth: False, uislnk: False, unlink: 1, uissock: False,
urgrp: True, ugr_name: uroot, upath:
u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
False, umode: u0644, urusr: True}]: open /home/ec2-user/[{uuid: 0,
uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False,
usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid:
0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
uissock: False, urgrp: True, ugr_name: uroot, upath:
u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
False, umode: u0644, urusr: True}]: file name too long"], "stdout":
"nInstalling artifact", "stdout_lines": ["", "Installing artifact"]}




and if i use:



 - name: deploy chef-automatev2
command: "chef-automate deploy config.toml --accept-terms-and-mlsa --skip-preflight --airgap-bundle {{ file_automate.files }}"


i get error:




TASK [deploy chef-automatev2]
**************************************************************************** fatal: [10.1.1.20]: FAILED! => {"changed": true, "cmd":
["chef-automate", "deploy", "config.toml", "--accept-terms-and-mlsa",
"--skip-preflight", "--airgap-bundle", "[{uuid:", "0,", "uwoth:",
"False,", "umtime:", "1540883970.2111344,", "uinode:", "83,",
"uisgid:", "False,", "usize:", "605693959,", "uisuid:", "False,",
"uisreg:", "True,", "upw_name:", "uroot,", "ugid:", "0,", "uischr:",
"False,", "uwusr:", "True,", "uxoth:", "False,", "uislnk:", "False,",
"unlink:", "1,", "uissock:", "False,", "urgrp:", "True,", "ugr_name:",
"uroot,", "upath:", "u/home/ec2-user/automate-20181020020209.aib,",
"uxusr:", "False,", "uatime:", "1540883969.7361338,", "uisdir:",
"False,", "uctime:", "1540883975.674141,", "uisblk:", "False,",
"uwgrp:", "False,", "uxgrp:", "False,", "udev:", "64768,", "uroth:",
"True,", "uisfifo:", "False,", "umode:", "u0644,", "urusr:",
"True}]"], "delta": "0:00:00.014548", "end": "2018-10-30
07:19:41.288141", "msg": "non-zero return code", "rc": 113, "start":
"2018-10-30 07:19:41.273593", "stderr": "Error: UnknownError: accepts
between 0 and 1 arg(s), received 62", "stderr_lines": ["Error:
UnknownError: accepts between 0 and 1 arg(s), received 62"], "stdout":
"", "stdout_lines": } to retry, use: --limit
@/home/ec2-user/ANSIBLE/clusterOps/roles/chef-automatev2/defaults/main.retry




was able to get the dictionary item:



- hosts: chefclusterautomatev2
remote_user: ec2-user
become: yes
become_method: sudo
connection: ssh
gather_facts: true
tasks:

- name: get aib filename
find:
paths: /home/ec2-user
register: res

- name: deploy chef-automatev2
debug:
msg: printing aib filename
with_items: "{{ res.files | map(attribute='path') | first}}"


Thanks to Matthew
i get at playbook run:



TASK [deploy chef-automatev2] *************************************************************************
ok: [1.1.1.17] => (item=/home/ec2-user/automate-20181019225406.aib) => {
"msg": "printing aib filename"
}


Now the question is how to use this object in "command" or "shell" ansible modules



Here is how I resolved the question of using the object in a shell command:



- hosts: localhost
remote_user: a3x52zz
connection: ssh
gather_facts: true
tasks:

- name: get aib filename
find:
paths: /Users/a3x52zz/ansible-test
file_type: "file"
patterns: "automate*.aib"
register: files_matched
- debug:
msg: "{{files_matched.files[1].path}}"

- name: cat filename
command: cat "{{files_matched.files[1].path}}"









share|improve this question




























    up vote
    0
    down vote

    favorite












    I am trying to install chef automate using chef habitat with ansible.



    here is the related section of main.yml



    - name: get aib filename
    find:
    paths: /home/ec2-user
    file_type: file
    use_regex: yes
    patterns:
    - '^automate.*'
    register: file_automate

    - name: deploy chef-automatev2
    command: "sudo chef-automate deploy '/home/ec2-user/config.toml' --accept-terms-and-mlsa --skip-preflight --airgap-bundle '/home/ec2-user/{{ file_automate.files }}'"


    but getting error:




    TASK [deploy chef-automatev2]
    ***************************************************************************fatal: [10.1.1.2]: FAILED! => {"changed": true, "cmd": ["sudo",
    "chef-automate", "deploy", "/home/ec2-user/config.toml",
    "--accept-terms-and-mlsa", "--skip-preflight", "--airgap-bundle",
    "/home/ec2-user/[{uuid: 0, uwoth: False, umtime: 1540882069.3233995,
    uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg:
    True, upw_name: uroot, ugid: 0, uischr: False, uwusr: True, uxoth:
    False, uislnk: False, unlink: 1, uissock: False, urgrp: True,
    ugr_name: uroot, upath: u/home/ec2-user/automate-20181020020209.aib,
    uxusr: False, uatime: 1540882068.8493989, uisdir: False, uctime:
    1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo: False, umode: u0644, urusr: True}]"],
    "delta": "0:00:00.026909", "end": "2018-10-30 06:48:00.362616", "msg":
    "non-zero return code", "rc": 94, "start": "2018-10-30
    06:48:00.335707", "stderr": "Error: DeployError: Unable to install,
    configure and start the service: Failed to unpack airgap artifact:
    Failed to open install bundle file /home/ec2-user/[{uuid: 0, uwoth:
    False, umtime: 1540882069.3233995, uinode: 82, uisgid: False, usize:
    605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0,
    uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
    uissock: False, urgrp: True, ugr_name: uroot, upath:
    u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
    1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
    False, umode: u0644, urusr: True}]: open /home/ec2-user/[{uuid: 0,
    uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False,
    usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid:
    0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
    uissock: False, urgrp: True, ugr_name: uroot, upath:
    u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
    1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
    False, umode: u0644, urusr: True}]: file name too long",
    "stderr_lines": ["Error: DeployError: Unable to install, configure and
    start the service: Failed to unpack airgap artifact: Failed to open
    install bundle file /home/ec2-user/[{uuid: 0, uwoth: False, umtime:
    1540882069.3233995, uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0, uischr: False,
    uwusr: True, uxoth: False, uislnk: False, unlink: 1, uissock: False,
    urgrp: True, ugr_name: uroot, upath:
    u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
    1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
    False, umode: u0644, urusr: True}]: open /home/ec2-user/[{uuid: 0,
    uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False,
    usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid:
    0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
    uissock: False, urgrp: True, ugr_name: uroot, upath:
    u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
    1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
    False, umode: u0644, urusr: True}]: file name too long"], "stdout":
    "nInstalling artifact", "stdout_lines": ["", "Installing artifact"]}




    and if i use:



     - name: deploy chef-automatev2
    command: "chef-automate deploy config.toml --accept-terms-and-mlsa --skip-preflight --airgap-bundle {{ file_automate.files }}"


    i get error:




    TASK [deploy chef-automatev2]
    **************************************************************************** fatal: [10.1.1.20]: FAILED! => {"changed": true, "cmd":
    ["chef-automate", "deploy", "config.toml", "--accept-terms-and-mlsa",
    "--skip-preflight", "--airgap-bundle", "[{uuid:", "0,", "uwoth:",
    "False,", "umtime:", "1540883970.2111344,", "uinode:", "83,",
    "uisgid:", "False,", "usize:", "605693959,", "uisuid:", "False,",
    "uisreg:", "True,", "upw_name:", "uroot,", "ugid:", "0,", "uischr:",
    "False,", "uwusr:", "True,", "uxoth:", "False,", "uislnk:", "False,",
    "unlink:", "1,", "uissock:", "False,", "urgrp:", "True,", "ugr_name:",
    "uroot,", "upath:", "u/home/ec2-user/automate-20181020020209.aib,",
    "uxusr:", "False,", "uatime:", "1540883969.7361338,", "uisdir:",
    "False,", "uctime:", "1540883975.674141,", "uisblk:", "False,",
    "uwgrp:", "False,", "uxgrp:", "False,", "udev:", "64768,", "uroth:",
    "True,", "uisfifo:", "False,", "umode:", "u0644,", "urusr:",
    "True}]"], "delta": "0:00:00.014548", "end": "2018-10-30
    07:19:41.288141", "msg": "non-zero return code", "rc": 113, "start":
    "2018-10-30 07:19:41.273593", "stderr": "Error: UnknownError: accepts
    between 0 and 1 arg(s), received 62", "stderr_lines": ["Error:
    UnknownError: accepts between 0 and 1 arg(s), received 62"], "stdout":
    "", "stdout_lines": } to retry, use: --limit
    @/home/ec2-user/ANSIBLE/clusterOps/roles/chef-automatev2/defaults/main.retry




    was able to get the dictionary item:



    - hosts: chefclusterautomatev2
    remote_user: ec2-user
    become: yes
    become_method: sudo
    connection: ssh
    gather_facts: true
    tasks:

    - name: get aib filename
    find:
    paths: /home/ec2-user
    register: res

    - name: deploy chef-automatev2
    debug:
    msg: printing aib filename
    with_items: "{{ res.files | map(attribute='path') | first}}"


    Thanks to Matthew
    i get at playbook run:



    TASK [deploy chef-automatev2] *************************************************************************
    ok: [1.1.1.17] => (item=/home/ec2-user/automate-20181019225406.aib) => {
    "msg": "printing aib filename"
    }


    Now the question is how to use this object in "command" or "shell" ansible modules



    Here is how I resolved the question of using the object in a shell command:



    - hosts: localhost
    remote_user: a3x52zz
    connection: ssh
    gather_facts: true
    tasks:

    - name: get aib filename
    find:
    paths: /Users/a3x52zz/ansible-test
    file_type: "file"
    patterns: "automate*.aib"
    register: files_matched
    - debug:
    msg: "{{files_matched.files[1].path}}"

    - name: cat filename
    command: cat "{{files_matched.files[1].path}}"









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to install chef automate using chef habitat with ansible.



      here is the related section of main.yml



      - name: get aib filename
      find:
      paths: /home/ec2-user
      file_type: file
      use_regex: yes
      patterns:
      - '^automate.*'
      register: file_automate

      - name: deploy chef-automatev2
      command: "sudo chef-automate deploy '/home/ec2-user/config.toml' --accept-terms-and-mlsa --skip-preflight --airgap-bundle '/home/ec2-user/{{ file_automate.files }}'"


      but getting error:




      TASK [deploy chef-automatev2]
      ***************************************************************************fatal: [10.1.1.2]: FAILED! => {"changed": true, "cmd": ["sudo",
      "chef-automate", "deploy", "/home/ec2-user/config.toml",
      "--accept-terms-and-mlsa", "--skip-preflight", "--airgap-bundle",
      "/home/ec2-user/[{uuid: 0, uwoth: False, umtime: 1540882069.3233995,
      uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg:
      True, upw_name: uroot, ugid: 0, uischr: False, uwusr: True, uxoth:
      False, uislnk: False, unlink: 1, uissock: False, urgrp: True,
      ugr_name: uroot, upath: u/home/ec2-user/automate-20181020020209.aib,
      uxusr: False, uatime: 1540882068.8493989, uisdir: False, uctime:
      1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo: False, umode: u0644, urusr: True}]"],
      "delta": "0:00:00.026909", "end": "2018-10-30 06:48:00.362616", "msg":
      "non-zero return code", "rc": 94, "start": "2018-10-30
      06:48:00.335707", "stderr": "Error: DeployError: Unable to install,
      configure and start the service: Failed to unpack airgap artifact:
      Failed to open install bundle file /home/ec2-user/[{uuid: 0, uwoth:
      False, umtime: 1540882069.3233995, uinode: 82, uisgid: False, usize:
      605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0,
      uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
      uissock: False, urgrp: True, ugr_name: uroot, upath:
      u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
      1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
      False, umode: u0644, urusr: True}]: open /home/ec2-user/[{uuid: 0,
      uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False,
      usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid:
      0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
      uissock: False, urgrp: True, ugr_name: uroot, upath:
      u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
      1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
      False, umode: u0644, urusr: True}]: file name too long",
      "stderr_lines": ["Error: DeployError: Unable to install, configure and
      start the service: Failed to unpack airgap artifact: Failed to open
      install bundle file /home/ec2-user/[{uuid: 0, uwoth: False, umtime:
      1540882069.3233995, uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0, uischr: False,
      uwusr: True, uxoth: False, uislnk: False, unlink: 1, uissock: False,
      urgrp: True, ugr_name: uroot, upath:
      u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
      1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
      False, umode: u0644, urusr: True}]: open /home/ec2-user/[{uuid: 0,
      uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False,
      usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid:
      0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
      uissock: False, urgrp: True, ugr_name: uroot, upath:
      u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
      1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
      False, umode: u0644, urusr: True}]: file name too long"], "stdout":
      "nInstalling artifact", "stdout_lines": ["", "Installing artifact"]}




      and if i use:



       - name: deploy chef-automatev2
      command: "chef-automate deploy config.toml --accept-terms-and-mlsa --skip-preflight --airgap-bundle {{ file_automate.files }}"


      i get error:




      TASK [deploy chef-automatev2]
      **************************************************************************** fatal: [10.1.1.20]: FAILED! => {"changed": true, "cmd":
      ["chef-automate", "deploy", "config.toml", "--accept-terms-and-mlsa",
      "--skip-preflight", "--airgap-bundle", "[{uuid:", "0,", "uwoth:",
      "False,", "umtime:", "1540883970.2111344,", "uinode:", "83,",
      "uisgid:", "False,", "usize:", "605693959,", "uisuid:", "False,",
      "uisreg:", "True,", "upw_name:", "uroot,", "ugid:", "0,", "uischr:",
      "False,", "uwusr:", "True,", "uxoth:", "False,", "uislnk:", "False,",
      "unlink:", "1,", "uissock:", "False,", "urgrp:", "True,", "ugr_name:",
      "uroot,", "upath:", "u/home/ec2-user/automate-20181020020209.aib,",
      "uxusr:", "False,", "uatime:", "1540883969.7361338,", "uisdir:",
      "False,", "uctime:", "1540883975.674141,", "uisblk:", "False,",
      "uwgrp:", "False,", "uxgrp:", "False,", "udev:", "64768,", "uroth:",
      "True,", "uisfifo:", "False,", "umode:", "u0644,", "urusr:",
      "True}]"], "delta": "0:00:00.014548", "end": "2018-10-30
      07:19:41.288141", "msg": "non-zero return code", "rc": 113, "start":
      "2018-10-30 07:19:41.273593", "stderr": "Error: UnknownError: accepts
      between 0 and 1 arg(s), received 62", "stderr_lines": ["Error:
      UnknownError: accepts between 0 and 1 arg(s), received 62"], "stdout":
      "", "stdout_lines": } to retry, use: --limit
      @/home/ec2-user/ANSIBLE/clusterOps/roles/chef-automatev2/defaults/main.retry




      was able to get the dictionary item:



      - hosts: chefclusterautomatev2
      remote_user: ec2-user
      become: yes
      become_method: sudo
      connection: ssh
      gather_facts: true
      tasks:

      - name: get aib filename
      find:
      paths: /home/ec2-user
      register: res

      - name: deploy chef-automatev2
      debug:
      msg: printing aib filename
      with_items: "{{ res.files | map(attribute='path') | first}}"


      Thanks to Matthew
      i get at playbook run:



      TASK [deploy chef-automatev2] *************************************************************************
      ok: [1.1.1.17] => (item=/home/ec2-user/automate-20181019225406.aib) => {
      "msg": "printing aib filename"
      }


      Now the question is how to use this object in "command" or "shell" ansible modules



      Here is how I resolved the question of using the object in a shell command:



      - hosts: localhost
      remote_user: a3x52zz
      connection: ssh
      gather_facts: true
      tasks:

      - name: get aib filename
      find:
      paths: /Users/a3x52zz/ansible-test
      file_type: "file"
      patterns: "automate*.aib"
      register: files_matched
      - debug:
      msg: "{{files_matched.files[1].path}}"

      - name: cat filename
      command: cat "{{files_matched.files[1].path}}"









      share|improve this question















      I am trying to install chef automate using chef habitat with ansible.



      here is the related section of main.yml



      - name: get aib filename
      find:
      paths: /home/ec2-user
      file_type: file
      use_regex: yes
      patterns:
      - '^automate.*'
      register: file_automate

      - name: deploy chef-automatev2
      command: "sudo chef-automate deploy '/home/ec2-user/config.toml' --accept-terms-and-mlsa --skip-preflight --airgap-bundle '/home/ec2-user/{{ file_automate.files }}'"


      but getting error:




      TASK [deploy chef-automatev2]
      ***************************************************************************fatal: [10.1.1.2]: FAILED! => {"changed": true, "cmd": ["sudo",
      "chef-automate", "deploy", "/home/ec2-user/config.toml",
      "--accept-terms-and-mlsa", "--skip-preflight", "--airgap-bundle",
      "/home/ec2-user/[{uuid: 0, uwoth: False, umtime: 1540882069.3233995,
      uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg:
      True, upw_name: uroot, ugid: 0, uischr: False, uwusr: True, uxoth:
      False, uislnk: False, unlink: 1, uissock: False, urgrp: True,
      ugr_name: uroot, upath: u/home/ec2-user/automate-20181020020209.aib,
      uxusr: False, uatime: 1540882068.8493989, uisdir: False, uctime:
      1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo: False, umode: u0644, urusr: True}]"],
      "delta": "0:00:00.026909", "end": "2018-10-30 06:48:00.362616", "msg":
      "non-zero return code", "rc": 94, "start": "2018-10-30
      06:48:00.335707", "stderr": "Error: DeployError: Unable to install,
      configure and start the service: Failed to unpack airgap artifact:
      Failed to open install bundle file /home/ec2-user/[{uuid: 0, uwoth:
      False, umtime: 1540882069.3233995, uinode: 82, uisgid: False, usize:
      605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0,
      uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
      uissock: False, urgrp: True, ugr_name: uroot, upath:
      u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
      1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
      False, umode: u0644, urusr: True}]: open /home/ec2-user/[{uuid: 0,
      uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False,
      usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid:
      0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
      uissock: False, urgrp: True, ugr_name: uroot, upath:
      u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
      1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
      False, umode: u0644, urusr: True}]: file name too long",
      "stderr_lines": ["Error: DeployError: Unable to install, configure and
      start the service: Failed to unpack airgap artifact: Failed to open
      install bundle file /home/ec2-user/[{uuid: 0, uwoth: False, umtime:
      1540882069.3233995, uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0, uischr: False,
      uwusr: True, uxoth: False, uislnk: False, unlink: 1, uissock: False,
      urgrp: True, ugr_name: uroot, upath:
      u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
      1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
      False, umode: u0644, urusr: True}]: open /home/ec2-user/[{uuid: 0,
      uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False,
      usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid:
      0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1,
      uissock: False, urgrp: True, ugr_name: uroot, upath:
      u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime:
      1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo:
      False, umode: u0644, urusr: True}]: file name too long"], "stdout":
      "nInstalling artifact", "stdout_lines": ["", "Installing artifact"]}




      and if i use:



       - name: deploy chef-automatev2
      command: "chef-automate deploy config.toml --accept-terms-and-mlsa --skip-preflight --airgap-bundle {{ file_automate.files }}"


      i get error:




      TASK [deploy chef-automatev2]
      **************************************************************************** fatal: [10.1.1.20]: FAILED! => {"changed": true, "cmd":
      ["chef-automate", "deploy", "config.toml", "--accept-terms-and-mlsa",
      "--skip-preflight", "--airgap-bundle", "[{uuid:", "0,", "uwoth:",
      "False,", "umtime:", "1540883970.2111344,", "uinode:", "83,",
      "uisgid:", "False,", "usize:", "605693959,", "uisuid:", "False,",
      "uisreg:", "True,", "upw_name:", "uroot,", "ugid:", "0,", "uischr:",
      "False,", "uwusr:", "True,", "uxoth:", "False,", "uislnk:", "False,",
      "unlink:", "1,", "uissock:", "False,", "urgrp:", "True,", "ugr_name:",
      "uroot,", "upath:", "u/home/ec2-user/automate-20181020020209.aib,",
      "uxusr:", "False,", "uatime:", "1540883969.7361338,", "uisdir:",
      "False,", "uctime:", "1540883975.674141,", "uisblk:", "False,",
      "uwgrp:", "False,", "uxgrp:", "False,", "udev:", "64768,", "uroth:",
      "True,", "uisfifo:", "False,", "umode:", "u0644,", "urusr:",
      "True}]"], "delta": "0:00:00.014548", "end": "2018-10-30
      07:19:41.288141", "msg": "non-zero return code", "rc": 113, "start":
      "2018-10-30 07:19:41.273593", "stderr": "Error: UnknownError: accepts
      between 0 and 1 arg(s), received 62", "stderr_lines": ["Error:
      UnknownError: accepts between 0 and 1 arg(s), received 62"], "stdout":
      "", "stdout_lines": } to retry, use: --limit
      @/home/ec2-user/ANSIBLE/clusterOps/roles/chef-automatev2/defaults/main.retry




      was able to get the dictionary item:



      - hosts: chefclusterautomatev2
      remote_user: ec2-user
      become: yes
      become_method: sudo
      connection: ssh
      gather_facts: true
      tasks:

      - name: get aib filename
      find:
      paths: /home/ec2-user
      register: res

      - name: deploy chef-automatev2
      debug:
      msg: printing aib filename
      with_items: "{{ res.files | map(attribute='path') | first}}"


      Thanks to Matthew
      i get at playbook run:



      TASK [deploy chef-automatev2] *************************************************************************
      ok: [1.1.1.17] => (item=/home/ec2-user/automate-20181019225406.aib) => {
      "msg": "printing aib filename"
      }


      Now the question is how to use this object in "command" or "shell" ansible modules



      Here is how I resolved the question of using the object in a shell command:



      - hosts: localhost
      remote_user: a3x52zz
      connection: ssh
      gather_facts: true
      tasks:

      - name: get aib filename
      find:
      paths: /Users/a3x52zz/ansible-test
      file_type: "file"
      patterns: "automate*.aib"
      register: files_matched
      - debug:
      msg: "{{files_matched.files[1].path}}"

      - name: cat filename
      command: cat "{{files_matched.files[1].path}}"






      ansible chef habitat






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 22:54

























      asked Oct 30 at 6:58









      kamal

      4,1932276125




      4,1932276125
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          If you were to read the error message, you would see that file_automate.files does not contain a list of filenames but rather contains a list of python objects, likely as the result of calling stat:



            "cmd": [
          "sudo",
          "chef-automate",
          "deploy",
          "/home/ec2-user/config.toml",
          "--accept-terms-and-mlsa",
          "--skip-preflight",
          "--airgap-bundle",
          "/home/ec2-user/[{uuid: 0, uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1, uissock: False, urgrp: True, ugr_name: uroot, upath: u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime: 1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo: False, umode: u0644, urusr: True}]"
          ],


          If you want just the list of filenames, {{ file_automate.files | map(attribute="path") | list }} should give that to you, although you'll want to omit the leading /home/ec2-user/ because as one can see, the path field of that object in files is already fully qualified.






          share|improve this answer





















          • I want to get only the filename "automate-20181020020209.aib" is there a way get only that name?
            – kamal
            Oct 30 at 11:33










          • my idea was to use regex '^automate.*' and return one filename
            – kamal
            Oct 30 at 11:40












          • I can't link directly to it, but the "useful filters" section contains the description of the basename filter, resulting in map(attribute="path") | map("basename") | list; however, if you only one then use | first instead of | list
            – Matthew L Daniel
            Oct 31 at 3:56












          • how would i use with_items: "{{ res.files | map(attribute='path') | first}}" as an object? i made additions to the question see ^^
            – kamal
            Nov 1 at 12:32











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53058903%2ffile-name-too-long-when-using-ansible-command-module%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          If you were to read the error message, you would see that file_automate.files does not contain a list of filenames but rather contains a list of python objects, likely as the result of calling stat:



            "cmd": [
          "sudo",
          "chef-automate",
          "deploy",
          "/home/ec2-user/config.toml",
          "--accept-terms-and-mlsa",
          "--skip-preflight",
          "--airgap-bundle",
          "/home/ec2-user/[{uuid: 0, uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1, uissock: False, urgrp: True, ugr_name: uroot, upath: u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime: 1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo: False, umode: u0644, urusr: True}]"
          ],


          If you want just the list of filenames, {{ file_automate.files | map(attribute="path") | list }} should give that to you, although you'll want to omit the leading /home/ec2-user/ because as one can see, the path field of that object in files is already fully qualified.






          share|improve this answer





















          • I want to get only the filename "automate-20181020020209.aib" is there a way get only that name?
            – kamal
            Oct 30 at 11:33










          • my idea was to use regex '^automate.*' and return one filename
            – kamal
            Oct 30 at 11:40












          • I can't link directly to it, but the "useful filters" section contains the description of the basename filter, resulting in map(attribute="path") | map("basename") | list; however, if you only one then use | first instead of | list
            – Matthew L Daniel
            Oct 31 at 3:56












          • how would i use with_items: "{{ res.files | map(attribute='path') | first}}" as an object? i made additions to the question see ^^
            – kamal
            Nov 1 at 12:32















          up vote
          1
          down vote



          accepted










          If you were to read the error message, you would see that file_automate.files does not contain a list of filenames but rather contains a list of python objects, likely as the result of calling stat:



            "cmd": [
          "sudo",
          "chef-automate",
          "deploy",
          "/home/ec2-user/config.toml",
          "--accept-terms-and-mlsa",
          "--skip-preflight",
          "--airgap-bundle",
          "/home/ec2-user/[{uuid: 0, uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1, uissock: False, urgrp: True, ugr_name: uroot, upath: u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime: 1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo: False, umode: u0644, urusr: True}]"
          ],


          If you want just the list of filenames, {{ file_automate.files | map(attribute="path") | list }} should give that to you, although you'll want to omit the leading /home/ec2-user/ because as one can see, the path field of that object in files is already fully qualified.






          share|improve this answer





















          • I want to get only the filename "automate-20181020020209.aib" is there a way get only that name?
            – kamal
            Oct 30 at 11:33










          • my idea was to use regex '^automate.*' and return one filename
            – kamal
            Oct 30 at 11:40












          • I can't link directly to it, but the "useful filters" section contains the description of the basename filter, resulting in map(attribute="path") | map("basename") | list; however, if you only one then use | first instead of | list
            – Matthew L Daniel
            Oct 31 at 3:56












          • how would i use with_items: "{{ res.files | map(attribute='path') | first}}" as an object? i made additions to the question see ^^
            – kamal
            Nov 1 at 12:32













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          If you were to read the error message, you would see that file_automate.files does not contain a list of filenames but rather contains a list of python objects, likely as the result of calling stat:



            "cmd": [
          "sudo",
          "chef-automate",
          "deploy",
          "/home/ec2-user/config.toml",
          "--accept-terms-and-mlsa",
          "--skip-preflight",
          "--airgap-bundle",
          "/home/ec2-user/[{uuid: 0, uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1, uissock: False, urgrp: True, ugr_name: uroot, upath: u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime: 1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo: False, umode: u0644, urusr: True}]"
          ],


          If you want just the list of filenames, {{ file_automate.files | map(attribute="path") | list }} should give that to you, although you'll want to omit the leading /home/ec2-user/ because as one can see, the path field of that object in files is already fully qualified.






          share|improve this answer












          If you were to read the error message, you would see that file_automate.files does not contain a list of filenames but rather contains a list of python objects, likely as the result of calling stat:



            "cmd": [
          "sudo",
          "chef-automate",
          "deploy",
          "/home/ec2-user/config.toml",
          "--accept-terms-and-mlsa",
          "--skip-preflight",
          "--airgap-bundle",
          "/home/ec2-user/[{uuid: 0, uwoth: False, umtime: 1540882069.3233995, uinode: 82, uisgid: False, usize: 605693959, uisuid: False, uisreg: True, upw_name: uroot, ugid: 0, uischr: False, uwusr: True, uxoth: False, uislnk: False, unlink: 1, uissock: False, urgrp: True, ugr_name: uroot, upath: u/home/ec2-user/automate-20181020020209.aib, uxusr: False, uatime: 1540882068.8493989, uisdir: False, uctime: 1540882074.7854095, uisblk: False, uwgrp: False, uxgrp: False, udev: 64768, uroth: True, uisfifo: False, umode: u0644, urusr: True}]"
          ],


          If you want just the list of filenames, {{ file_automate.files | map(attribute="path") | list }} should give that to you, although you'll want to omit the leading /home/ec2-user/ because as one can see, the path field of that object in files is already fully qualified.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 30 at 8:20









          Matthew L Daniel

          7,26612326




          7,26612326












          • I want to get only the filename "automate-20181020020209.aib" is there a way get only that name?
            – kamal
            Oct 30 at 11:33










          • my idea was to use regex '^automate.*' and return one filename
            – kamal
            Oct 30 at 11:40












          • I can't link directly to it, but the "useful filters" section contains the description of the basename filter, resulting in map(attribute="path") | map("basename") | list; however, if you only one then use | first instead of | list
            – Matthew L Daniel
            Oct 31 at 3:56












          • how would i use with_items: "{{ res.files | map(attribute='path') | first}}" as an object? i made additions to the question see ^^
            – kamal
            Nov 1 at 12:32


















          • I want to get only the filename "automate-20181020020209.aib" is there a way get only that name?
            – kamal
            Oct 30 at 11:33










          • my idea was to use regex '^automate.*' and return one filename
            – kamal
            Oct 30 at 11:40












          • I can't link directly to it, but the "useful filters" section contains the description of the basename filter, resulting in map(attribute="path") | map("basename") | list; however, if you only one then use | first instead of | list
            – Matthew L Daniel
            Oct 31 at 3:56












          • how would i use with_items: "{{ res.files | map(attribute='path') | first}}" as an object? i made additions to the question see ^^
            – kamal
            Nov 1 at 12:32
















          I want to get only the filename "automate-20181020020209.aib" is there a way get only that name?
          – kamal
          Oct 30 at 11:33




          I want to get only the filename "automate-20181020020209.aib" is there a way get only that name?
          – kamal
          Oct 30 at 11:33












          my idea was to use regex '^automate.*' and return one filename
          – kamal
          Oct 30 at 11:40






          my idea was to use regex '^automate.*' and return one filename
          – kamal
          Oct 30 at 11:40














          I can't link directly to it, but the "useful filters" section contains the description of the basename filter, resulting in map(attribute="path") | map("basename") | list; however, if you only one then use | first instead of | list
          – Matthew L Daniel
          Oct 31 at 3:56






          I can't link directly to it, but the "useful filters" section contains the description of the basename filter, resulting in map(attribute="path") | map("basename") | list; however, if you only one then use | first instead of | list
          – Matthew L Daniel
          Oct 31 at 3:56














          how would i use with_items: "{{ res.files | map(attribute='path') | first}}" as an object? i made additions to the question see ^^
          – kamal
          Nov 1 at 12:32




          how would i use with_items: "{{ res.files | map(attribute='path') | first}}" as an object? i made additions to the question see ^^
          – kamal
          Nov 1 at 12:32


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53058903%2ffile-name-too-long-when-using-ansible-command-module%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Lugert, Oklahoma