Upaya in Theravada Buddhism and the Pali Canon According to the article An Explanation of Upaya in Buddhism by Barbara O'Brien:


  Mahayana Buddhists often use the word upaya, which is translated
  "skillful means" or "expedient means." Very simply, upaya is any
  activity that helps others realize enlightenment. Sometimes upaya is
  spelled upaya-kausalya, which is "skill in means."
  
  Upaya can be unconventional; something not normally associated with
  Buddhist doctrine or practice. The most important points are that the
  action is applied with wisdom and compassion and that it is
  appropriate in its time and place. .....
  
  In Theravada Buddhism, upaya refers to the Buddha's skill in shaping
  his teaching to be appropriate to his audience—simple doctrines and
  parables for beginners; more advanced teaching for senior students.
  Mahayana Buddhists see the historical Buddha's teachings as
  provisional, preparing the ground for the later Mahayana teachings
  (see "Three Turnings of the Dharma Wheel").
  
  According to some sources just about anything is allowable as upaya,
  including breaking the Precepts. Zen history is full of accounts of
  monks realizing enlightenment after being struck or shouted at by a
  teacher. In one famous story, a monk realized enlightenment when his
  teacher slammed a door on his leg and broke it.
  
  Obviously, this no-holds-barred approach potentially could be abused.


Upaya or "skillful means" is a popular concept in Mahayana Buddhism. When the Buddha tells one thing to one audience and another thing to another audience, based on their specific needs, this is considered upaya.

It might be the case that the teaching to one audience is completely the opposite to the teaching to the other audience in Mahayana Buddhism.

In certain Mahayana traditions, the teacher may even break the precepts (for example, drinking alcohol), or shout at or hit the disciples, as part of the skillful means (upaya) to teach them.


Does this exist in Theravada Buddhism?
Please provide examples of upaya from the Pali Canon.
From the Pali Canon or Theravada Buddhism, would the Buddha even tell completely opposite things to different audiences?
From the Pali Canon or Theravada Buddhism, could the Buddha break his own rules, or even do things like shouting or hitting in order to teach his disciples?
AFAIK, breaking precepts that result in unwholesome Karma is never excused in Theravada Buddhism. Especially the five precepts.

Here are few examples of the Buddha using Upaya:


Showing nymphs to prince Nanada to break his attachment towards Janapada Kalyani.
Breaking Khema's infatuation with beauty by showing a beautiful maiden deteriorate in front of her eyes.
Teaching the stanzas to old brahmin who was mistreated by his four sons.


There might be teachings that appear complete opposite if you take the literal meaning of the words or disregard the context. But the teachings never conflict when you understand the full picture.

The Buddha would scold a monk to get him disciplined, but he would never use physical force. Such a need wouldn't even arise to the Buddha. Although monks are allowed by Vinaya to strike another in self defence.

The Buddha may decide not to keep to a lesser(non-offensive) Vinaya rule on certain occasions, but the monks do not have this freedom.