ansible/ansible

uri: sourcing vaulted file doesn't work

Open

#60,632 opened on Aug 15, 2019

View on GitHub
 (16 comments) (1 reaction) (0 assignees)Python (24,176 forks)batch import
P3affects_2.8easyfixfeaturehacktoberfesthas_prmodule

Repository metrics

Stars
 (68,548 stars)
PR merge metrics
 (Avg merge 8d 18h) (74 merged PRs in 30d)

Description

SUMMARY

I'm using uri module to send the vaulted file, but Ansible doesn't decrypt it.

    uri:
      url: "http://localhost:8888/"
      method: POST
      src: file-encrypted.json

Instead, it's sending raw vault format, despite specifying --ask-vault-pass.

ISSUE TYPE
  • Bug Report
  • Feature Idea
COMPONENT NAME

uri

ANSIBLE VERSION
ansible 2.8.0
CONFIGURATION

n/a

OS / ENVIRONMENT

macOS

STEPS TO REPRODUCE
  1. Create a file.json with {'foo': 'bar'} content.
  2. Vault it via: ansible-vault encrypt file.json
  3. Create the following playbook (e.g. uri.yml):
---
- hosts: localhost
  tasks:
  - name: Send JSON file
    uri:
      url: "http://localhost:8888/"
      method: POST
      src: file.json
      headers:
        Content-Type: "application/json"
  1. On the other terminal, run the netcat on port 8888: nc -vl 8888.
  2. Run playbook via: ansible-playbook uri.yml --ask-vault-pass -vvv
EXPECTED RESULTS

Original content of JSON file is sent.

ACTUAL RESULTS

Encrypted version is received instead:

$  nc -vl 8888
POST / HTTP/1.1
Accept-Encoding: identity
Host: localhost:8888
User-Agent: ansible-httpget
Content-Type: application/json
Content-Length: 355
Connection: close

$ANSIBLE_VAULT;1.1;AES256
39373739353265643239323865303463303638656538663366663330343835353834306462646232
3332326234303438396263663337646134393563333165640a616433366364666161366231326463

Contributor guide