Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

Access denied creating setting up SSH keys #40

Open
aloysius-lim opened this issue Dec 23, 2015 · 0 comments
Open

Access denied creating setting up SSH keys #40

aloysius-lim opened this issue Dec 23, 2015 · 0 comments

Comments

@aloysius-lim
Copy link

The common role does not have the right permissions to create the .ssh folder, nor copy the SSH keys. The fix is the add sudo: yes to these four places in roles/common/tasks/main.yml:

- name: Go's .ssh folder
  sudo: yes
  file: path=/var/go/.ssh state=directory group={{ GOCD_GROUP }} owner={{ GOCD_USER }}
  when: GOCD_CONFIGURE_SSH

- name: SSH public key
  sudo: yes
  copy: "dest=/var/go/.ssh/{{ GOCD_SSH_PUBLIC_KEY | basename}} src='{{ GOCD_SSH_PUBLIC_KEY }}' group={{ GOCD_GROUP }} mode=0644 owner={{ GOCD_USER }}"
  when: GOCD_CONFIGURE_SSH

- name: SSH private key
  sudo: yes
  copy: "dest=/var/go/.ssh/{{ GOCD_SSH_PRIVATE_KEY | basename}} src='{{ GOCD_SSH_PRIVATE_KEY }}' group={{ GOCD_GROUP }} mode=0600 owner={{ GOCD_USER }}"
  when: GOCD_CONFIGURE_SSH

- name: ensure git server is a known host
  sudo: yes
  lineinfile:
    dest: /var/go/.ssh/known_hosts
    create: yes
    state: present
    line: "{{ lookup('pipe', 'ssh-keyscan -t rsa ' + GOCD_SSH_KNOWN_DOMAIN) }}"
    regexp: "^{{ GOCD_SSH_KNOWN_DOMAIN|replace('.', '\\.') }}"
    group: "{{ GOCD_GROUP }}"
    mode: 0644
    owner: "{{ GOCD_USER }}"
  when: GOCD_CONFIGURE_SSH
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant