Skip to content
Snippets Groups Projects
Select Git revision
  • f936dae06fdd4148181c4d201c414a8e7fe3cf30
  • master default
2 results

playbook.yml

Blame
  • playbook.yml 2.41 KiB
    ---
    - hosts: gitreceive-openbsd*
      gather_facts: false
      roles:
          - openbsd-bootstrap
          - role: users
            users: []
            users_use_sudo: True
            users_lock_root_ssh: False
    
    - hosts: [gitreceive-xenial, gitreceive-wheezy]
      gather_facts: false
      roles:
          - debian-bootstrap
          - role: users
            users: []
            users_use_sudo: True
            users_lock_root_ssh: False
    
    - hosts: all
      tasks:
          - name: Create SSH keypair
            become: False
            local_action: command ssh-keygen -t rsa -N '' -f files/id_rsa
            run_once: True
            args:
                creates: files/id_rsa
    
          - name: Install SSH server
            when: ansible_pkg_mgr == 'apt'
            apt:
                name: openssh-server
                state: present
    
          - name: Create sshd run directory
            when: ansible_os_family == 'Debian'
            file:
                path: /var/run/sshd
                owner: root
                group: root
                mode: 0o0755
                state: directory
    
          - name: Start SSH service
            when: ansible_pkg_mgr == 'apt'
            service:
                name: ssh
                state: started
    
    - hosts: all
      roles:
          - role: gitreceive
            gitreceive_public_keys: ['{{ lookup("file", "id_rsa.pub") }}']
            gitreceive_receiver_script: '{{ lookup("file", "files/receiver.sh") }}'
      post_tasks:
          - name: Create .ssh directory
            file:
                path: /root/.ssh
                owner: root
                group: 0
                mode: 0o0700
                state: directory
    
          - name: Copy SSH keypair
            with_items:
                - id_rsa
                - id_rsa.pub
            copy:
                src: '{{ item }}'
                dest: '/root/.ssh/{{ item }}'