Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra new-lines using copy module (using content) and lineinfile in V 1.8 #8989

Closed
mm0 opened this issue Sep 12, 2014 · 5 comments
Closed

Extra new-lines using copy module (using content) and lineinfile in V 1.8 #8989

mm0 opened this issue Sep 12, 2014 · 5 comments
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release

Comments

@mm0
Copy link

mm0 commented Sep 12, 2014

Tested using this playbook:

  • hosts: localhost
    connection: local
    vars:
    outfilefail1: ./outcertfail1
    working_outfile1: ./outcert_working
    working_outfile2: ./outcert_working2
    certificate: |
    -----BEGIN RSA PRIVATE KEY-----
    MIIEpAIBAAKCAQEApj8FWvKE5k4HfnZPHEM4b39LxmYiHyfUnemg4ywT4ydeyr2I
    l0EiNQt9yMLr3jAuWFZE/+KTD2GPONIuOCEMwWrF0sBSP5cdndjwQqwIcL7YXNE+
    4C1IT/GaNNGwolQXxSRzSSnBIAG9XplvAvdu+NjEVaha46L7XAiYWCU19UkwVITg
    6hvfRkN6iVXzn5UolHbcMqHJB6/O7ItVZl/TEW5Ehc0+06q5BLHNvUaVX3ujy1sO
    xxr9XZpTcYesTFcQUyI4KSphcYzJa0oRJrM8b0mLuAKGh4RBbxiMT65AYJz9wv5R
    l4KnR6WZgwgU0oajdebJ5hayUIt46sCPP4jCvwIDAQABAoIBAGe1oO2fpXDW9K3b
    uHZ1KNvFmcvnIxo0itsISCnv8Wgfw27O1kslguV8ibeYgfRWMlNBXkITYpKR1fso
    g1TYqVBv/4D+IVEyQHOcRiYRlCJhrDAbCRJorVfR7NVOitZ5h2qg1pqpxaTl8PD2
    3t4G5d+vuquFH04q+ovrgL5cWFDvmgyMz/hRFChwTDWpiP4dQUQXJkqf1gzGIAb9
    cfu/kuyc2M6iPPAuFdWgVaG2V52ZHP7eVTZibEj3uu2BKA03fQtaaGz1Js10dVDP
    LQYAHjGNiYtJOvT6N6En38XXykDDQ/3LLwRJ+S0r7y7F6XD5BfZsYu+yFFAGN/XY
    I1IJa8ECgYEA1BlI4rHvkKgGWka5Hs2A1I+GW2Fbh/9WeKXOy/Klvcx6VqTerzGu
    qVViREvITaMTXaV+aN1ZHaw9aQjtRtaIv3Q+QgG0iz8xdeyCAdB3Nz+sEreSK/nt
    Z4W/uBsqL7EX+Ft52qJ3AFM9VEyE0sN81m4PDgbCbSRyy63nVNNNvkcCgYEAyKgX
    7EEIcAVG8K9HQYZGUyjHQwRH4LmgdseXYwxgGXNwxujaQEU39baivvRvuEuRgmKA
    7WqS2EhrCuLauyEaBGk5v0GZVD1Br67xWZ4JGXz8QRFaWU/eDfZGKdpzlYDsdVSW
    ZJOO9i6bvRfsk74Fxmv9JREqUTtCOpl+rYw8O8kCgYB0GYseHEyIoJEppYD77X3R
    3Oas6rQR06Ff1VNHrIExTdbByunieI2lP4nU3K6+YL/fCRITEOcRKRFMh4hquFCO
    jHDv7MMJXgQTCu13VMeNRJtKe5XV4K8ldb8mZihHhucaGeiv1zLQyL/PfztNq5iQ
    QBqZkPWojMUR3RW+BxSNTQKBgQDCemENY46o/ARgvJGEiX7ZlLlkU97SiTdkSFiK
    8HCn2kJhF0iJaE0vgn9EMqehaOS0CYLKGTQQGkhdObgkDJYp1k7Y9tyEUAa9HwLf
    CBPrtz7KVeZKj+U5hQtF/2ttaJJFueE1w+qY4l2hrXFnVJJGWV32MifgqV2sbB7i
    V/v9OQKBgQC/khRqBF78r+c+IBD8qwFsul1q/1+GjHGniJVT11n0TaFA7uG8X5PM
    P5TsBigLmNGk/44Tg3fe9iCZXVB09CMqJNdaxqhCvwjj8WJ+wkEY5yhv+lHehHUh
    Njyac1N+crBFEd2Suww9Md9H9Sg/5AJW/lY5Ek9CRAG1LvAengbGdQ==
    -----END RSA PRIVATE KEY-----
    tasks:
    • name: fails
      copy: content="{{ certificate }}" dest="{{ outfilefail1 }}"
    • name: fails
      lineinfile: line="{{ certificate }}" dest="{{ outfilefail1 }}" create=yes
    • name: works
      copy:
      content: |
      {{ certificate }}
      dest: "{{ working_outfile1 }}"
    • name: works
      copy:
      content: >
      {{ certificate }}
      dest: "{{ working_outfile2 }}"

Please assume that all the indentation is correct, I wasn't sure how to do that here. I just created a key using ssh-keygen for the certificate variable. I noticed that the first fail example (using the copy module) adds two newlines between each line, and lineinfile only adds one extra, both of which are wrong. I also included two working methods of doing this. All 4 examples work correctly in 1.7.1, but on 1.8 only the last 2 work.

@ansibot
Copy link
Contributor

ansibot commented Sep 12, 2014

Can You Help Us Out?

Thanks for filing a ticket! I am the friendly GitHub Ansibot.

It looks like you might not have filled out the issue description based on our standard issue template. You might not have known about that, and that's ok too, we'll tell you how to do it.

We have a standard template because Ansible is a really busy project and it helps to have some standard information in each ticket, and GitHub doesn't yet provide a standard facility to do this like some other bug trackers. We hope you understand as this is really valuable to us!.

Solving this is simple: please copy the contents of this template and paste it into the description of your ticket. That's it!

If You Had A Question To Ask Instead

If you happened to have a "how do I do this in Ansible" type of question, that's probably more of a user-list question than a bug report, and you should probably ask this question on the project mailing list instead.

However, if you think you have a bug, the report is the way to go! We definitely want all the bugs filed :) Just trying to help!

About Priority Tags

Since you're here, we'll also share some useful information at this time.

In general tickets will be assigned a priority between P1 (highest) and P5, and then worked in priority order. We may also have some follow up questions along the way, so keeping up with follow up comments via GitHub notifications is a good idea.

Due to large interest in Ansible, humans may not comment on your ticket immediately.

Mailing Lists

If you have concerns or questions, you're welcome to stop by the ansible-project or ansible-development mailing lists, as appropriate. Here are the links:

Thanks again for the interest in Ansible!

@mpdehaan
Copy link
Contributor

Definitely going to look into this, though the easiest solution would be to use the copy module with the src param to get that going, or pass hash arguments to copy.

Wanted to make that clear so immediate solutions are evident.

@oskarpearson
Copy link

Apologies for a 'Me too' here - but I'd really like to see this fixed before 1.8 is released. If someone could add a priority to this bug I'd appreciate it, so that things don't get forgotten.

I currently use the 'copy... content=' convention for managing /etc/ssh/ssh_host_rsa_key and similar, with the contents stored in vault files. Galaxy role at: https://galaxy.ansible.com/list#/roles/1220

If v1.8 goes live with this bug I could end up locked out of systems I maintain, since SSH refuses to start with mangled host keys.

Thanks!

@jimi-c jimi-c added P2 Priority 2 - Issue Blocks Release bug_report labels Sep 15, 2014
@mpdehaan
Copy link
Contributor

Hi!

Thanks very much for your interest in Ansible. It sincerely means a lot to us.

On September 26, 2014, due to enormous levels of contribution to the project Ansible decided to reorganize module repos, making it easier
for developers to work on the project and for us to more easily manage new contributions and tickets.

We split modules from the main project off into two repos, http://github.com/ansible/ansible-modules-core and http://github.com/ansible/ansible-modules-extras

If you would still like this ticket attended to, we will need your help in having it reopened in one of the two new repos, and instructions are provided below.

We apologize that we are not able to make this transition happen seamlessly, though this is a one-time change and your help is greatly appreciated --
this will greatly improve velocity going forward.

Both sets of modules will ship with Ansible, though they'll receive slightly different ticket handling.

To locate where a module lives between 'core' and 'extras'

Additionally, should you need more help with this, you can ask questions on:

Thank you very much!

@oskarpearson
Copy link

Transitioned to new issue in ansible/ansible-modules-core - see above.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release
Projects
None yet
Development

No branches or pull requests

5 participants