通用-2_git_privatekey.yaml
-
提前生成rsa格式的密钥对
ssh-keygen -t rsa -b 4096 -f ~/.ssh/gitkey -C "email@email.cn"- 然后把公钥登记到对应的仓库中
-
脚本内容
- hosts: prod vars: gitkey_path: /home/ubuntu/.ssh/gitkey tasks: - name: Upload the private key used for Git copy: src: "{{ gitkey_path }}" dest: "{{ gitkey_path }}" - name: Correct private key permissions file: dest: "{{ gitkey_path }}" mode: 0600