首先, 执行以下脚本, 安装homebrew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
选第一个,测试过后,感觉第一个比较稳, 输入Mac管理员密码,开始安装homebrew
安装过程
appledeMacBook-Air:~ lingye$ /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
开始执行Brew自动安装程序
[[email protected]]
['2021-07-05 16:20:40']['10.14']
https://zhuanlan.zhihu.com/p/111014448
请选择一个下载镜像,例如中科大,输入1回车。
源有时候不稳定,如果git克隆报错重新运行脚本选择源。cask非必须,有部分人需要。
1、中科大下载源 2、清华大学下载源 3、北京外国语大学下载源 4、腾讯下载源(不推荐) 5、阿里巴巴下载源(不推荐 缺少cask源)
请输入序号: 1
你选择了中国科学技术大学下载源
!!!此脚本将要删除之前的brew(包括它下载的软件),请自行备份。
->是否现在开始执行脚本(N/Y) y
--> 脚本开始执行
Mac os设置开机密码方法:
(设置开机密码:在左上角苹果图标->系统偏好设置->用户与群组->更改密码)
(如果提示This incident will be reported. 在用户与群组中查看是否管理员)
==> 通过命令删除之前的brew、创建一个新的Homebrew文件夹
请输入开机密码,输入过程不显示,输入完后回车
Password:
开始执行
-> 创建文件夹 /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /usr/local/Homebrew
此步骤成功
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown lingye /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew
git version 2.15.0
下载速度觉得慢可以ctrl+c或control+c重新运行脚本选择下载源
==> 克隆Homebrew基本文件
未发现Git代理(属于正常状态)
Cloning into '/usr/local/Homebrew'...
remote: Enumerating objects: 194146, done.
remote: Total 194146 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (194146/194146), 49.83 MiB | 2.44 MiB/s, done.
Resolving deltas: 100% (144890/144890), done.
此步骤成功
--创建Brew所需要的目录
运行代码 ==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/share/zsh /usr/local/share/zsh/site-functions
运行代码 ==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/Cellar /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /usr/sbin/chown lingye /usr/local/Cellar /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Cellar /usr/local/Caskroom
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R lingye:admin /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /bin/mkdir -p /Users/lingye/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /bin/chmod g+rwx /Users/lingye/Library/Caches/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown -R lingye /Users/lingye/Library/Caches/Homebrew
--依赖目录脚本运行完成
==> 创建brew的替身
==> 克隆Homebrew Core
此处如果显示Password表示需要再次输入开机密码,输入完后回车
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 986631, done.
remote: Total 986631 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (986631/986631), 394.64 MiB | 2.34 MiB/s, done.
Resolving deltas: 100% (679933/679933), done.
此步骤成功
==> 克隆Homebrew Cask 图形化软件
此处如果显示Password表示需要再次输入开机密码,输入完后回车
Password:
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 631929, done.
remote: Total 631929 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (631929/631929), 265.00 MiB | 2.36 MiB/s, done.
Resolving deltas: 100% (451365/451365), done.
此步骤成功
==> 克隆Homebrew services 管理服务的启停
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 1141, done.
remote: Counting objects: 100% (1141/1141), done.
remote: Compressing objects: 100% (495/495), done.
remote: Total 1141 (delta 484), reused 1141 (delta 484), pack-reused 0
Receiving objects: 100% (1141/1141), 331.50 KiB | 642.00 KiB/s, done.
Resolving deltas: 100% (484/484), done.
此步骤成功
==> 配置国内镜像源HOMEBREW BOTTLE
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /Users/lingye/.bash_profile
运行代码 ==> /usr/bin/sudo /usr/sbin/chown lingye /Users/lingye/.bash_profile
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /Users/lingye/.bash_profile
环境变量写入->/Users/lingye/.bash_profile
此步骤成功
运行代码 ==> /usr/bin/sudo /bin/chmod -R a+rwx /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/sbin/chown lingye /usr/local/Homebrew
运行代码 ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Homebrew
==> 安装完成,brew版本
Homebrew 3.2.0-130-g35b15af-dirty
Homebrew/homebrew-core (git revision 68e25d814a; last commit 2021-07-05)
Homebrew/homebrew-cask (git revision 6b501c98ad; last commit 2021-07-05)
Brew前期配置成功
检测到你不是最新系统,会有一些报错,请稍等Ruby下载安装;
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
All user-space services OK, nothing cleaned...
==> brew update-reset
==> Fetching /usr/local/Homebrew...
==> Resetting /usr/local/Homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.
==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.
==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.
==> Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services...
==> Resetting /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Reset branch 'master'
Your branch is up to date with 'origin/master'.
Brew自动安装程序运行完成
国内地址已经配置完成
桌面的Old_Homebrew文件夹,大致看看没有你需要的可以删除。
初步介绍几个brew命令
本地软件库列表:brew ls
查找软件:brew search google(其中google替换为要查找的关键字)
查看brew版本:brew -v 更新brew版本:brew update
安装cask软件:brew install --cask firefox 把firefox换成你要安装的
欢迎右键点击下方地址-打开URL 来给点个赞
https://zhuanlan.zhihu.com/p/111014448
重启终端 或者 运行 source /Users/lingye/.bash_profile 否则可能无法使用
重新开一个终端, 执行以下脚本
brew instanll ansible
执行完毕后, 会自动跳出脚本, 然后咱们就可以自由输入了
执行ansible -m ping 127.0.0.1, 出现以下提示说明安装成功, 可以搞事情了
appledeMacBook-Air:~ lingye$ ansible -m ping 127.0.0.1
[WARNING]: No inventory was parsed, only implicit localhost is available
127.0.0.1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
ansible配置
# 创建配置文件目录
sudo mkdir /etc/ansible
vi /etc/ansible/ansible.cfg
------------------------------------ 以下为内容 ------
[defaults] # 通用默认配置段
inventory = /etc/ansible/hosts # 被控制端IP或者DNS列表
# library = /usr/share/my_modules/ # ansible默认搜寻模块的位置
remote_tmp = $HOME:/.ansible/tmp # ansible远程执行临时文件
forks = 10 # 并行进程数
sudo_user = root # sudo远程执行用户名
ask_sudo_pass = True # 使用sudo,是否需要输入密码
ask_pass = True # 是否需要输入密码
remote_port = 22 # 远程SSH端口
module_lang = C # 模块和系统之间通信的语言
host_key_checking = False # 检查远程主机密钥
#sudo_exec = sudo # sudo远程执行命令
#sudo_flags = -H # 传递sudo之外的参数
timeout = 10 # SSH超时时间
remote_user = root # 远程登陆用户名
log_path = /var/log/ansible.log # 日志文件存放路径
module_name = command # ansible命令执行默认的模块
#executable = /bin/bash # 执行的shell环境,使用shell模块
#system_marnings = True # 禁用系统运行ansible潜在问题警告
#command_warnings = False # command模块ansible模块默认发出的警告
#nocolor = 1 # 输出带上颜色区别,开启/关闭: 0/1
pipelining = False # 开启pipe SSH通道优化