Walgreens Boots Alliance said Tuesday that it has agreed to buy Rite Aid, one of its largest rivals, for $17.2 billion, including debt. Walgreens' shares rose more than 4 percent after The Wall Street Journal reported earlier in the day that the two companies were in advanced talks on a deal.