欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Ansible自动化配置Flutter环境

程序员文章站 2022-07-05 21:34:27
安装:python>2.6brew install ansiblebrew install http://git.io/sshpass.rbansible --versionhostsall: children: servers: hosts: 10.23.2.147: ansible_ssh_user: xxxx ansible_ssh_pass: "xxxx123" ....

安装:

python>2.6

brew install ansible

brew install http://git.io/sshpass.rb

ansible --version

 

hosts

all:
  children:
    servers:
      hosts:
        10.23.2.147:
          ansible_ssh_user: xxxx
          ansible_ssh_pass: "xxxx123"
          ansible_become_pass: "xxxx123"

 

need_copy_flutter.sh

#!/bin/sh

# 判断是否需要拉取 flutter
function NEED_COPY_HISTORY() {
	if [ -d "/Users/live/flutter/" ]; then
		cd ~/flutter
		NEED_COPY_FLUTTER=$(git status | grep v1.9.1 | wc -l)
		if [ NEED_COPY_FLUTTER > 0 ]; then 
			return
		fi
	fi 
	echo "need copy flutter"
}

NEED_COPY_HISTORY

 

 

playbook文件

xxxx.yaml

---
- hosts: servers
  remote_user: root
  tasks:
    - name: copy shell script
      copy: dest=test src=/etc/ansible/test.sh
    - name: execute shell script
      shell: sh test/test.sh

 

在所有host执行playbook

ansible-playbook xxxx.yaml

 

配置流程

手动执行xcode-select --install,权限问题

传输xcode 10g 14min30s

传输Android sdk 17.18g 20min

 

问题记录

1、执行xcode-select --install安装命令行开发工具会弹窗

解决方案:使用AppleScript点击确认

xcode-select --install
sleep 1

osascript <<EOD
  tell application "System Events"
    tell process "Install Command Line Developer Tools"
      keystroke return
      click button "Agree" of window "License Agreement"
    end tell
  end tell
EOD

AppleScript执行过程中发现需要控制权限【待解决】

Ansible自动化配置Flutter环境

点击确认之后还会有个协议需要点击同意

 

2、flutter doctor执行过程中

Agreeing to the Xcode/iOS license requires admin privileges

sudo xcodebuild -license

之后阅读证书需要space翻页到底,键入agree回车

 

 

3、flutter doctor执行过程中。

弹窗需要输入密码,点击安装软件

Ansible自动化配置Flutter环境

 

4、android证书

flutter doctor --android-licenses

需要两次y回车

 

5、测试的host机器环境是macOS Catelina 10.15.2,其他版本弹窗、权限等可能情况不完全一样。

 

本文地址:https://blog.csdn.net/ybhy123/article/details/108706923